Вы находитесь на странице: 1из 58

EJERCICIO DE PRCTICA 3.

1
1. Use el comando help en la ventana de comandos para encontrar la sintaxis

adecuada para las siguientes funciones:


a. cos
b. sqrt
c. exp
>> help cos
COS
Cosine of argument in radians.
COS(X) is the cosine of the elements of X.
See also acos, cosd.
Overloaded methods:
codistributed/cos
Reference page in Help browser
doc cos
>> help sqrt
SQRT
Square root.
SQRT(X) is the square root of the elements of X.
Complex
results are produced if X is not positive.
See also sqrtm, realsqrt, hypot.
Overloaded methods:
codistributed/sqrt
Reference page in Help browser
doc sqrt
>> help exp
EXP
Exponential.
EXP(X) is the exponential of the elements of X, e to
the X.
For complex Z=X+i*Y, EXP(Z) = EXP(X)*(COS(Y)
+i*SIN(Y)).
See also expm1, log, log10, expm, expint.
Overloaded methods:
lti/exp
codistributed/exp
fints/exp
Reference page in Help browser
doc exp
2. Use la funcin de ayuda en ventana de la barra de men para aprender

acerca de las funciones en el problema 1.

3. Vaya a la funcin de ayuda en lnea en www.mathworks.com para aprender

acerca de las funciones en el problema 1.


Ejercicio de prctica 3.2
1. Cree un vector x de 22 a +2 con un incremento de 1. Su vector debe ser
a. Encuentre el valor absoluto de cada miembro del vector.
b. Encuentre la raz cuadrada de cada miembro del vector.
>> x=-2:1:2
x =
-2
-1
>> abs(x)
ans =
2
1

>> sqrt(x)
ans =
Columns 1 through 2
0 + 1.4142i
0 + 1.0000i
Columns 3 through 4
0
1.0000
Column 5
1.4142
2. Encuentre la raz cuadrada de 23 y +3.
a. Use la funcin sqrt.
b. Use la funcin nthroot.
c. Eleve 23 y +3 a la potencia .
Cmo vara el resultado?
>> sqrt (-3)
ans =
0 + 1.7321i
>> sqrt (3)
ans =
1.7321
3. Cree un vector x de 210 a 11 con un incremento de 3.
a. Encuentre el resultado de x dividido entre 2.
b. Encuentre el residuo de x dividido entre 2.
>> x=-10:3:11
x =
Columns 1 through 7
-10
-7
-4
-1
2
5
8
Column 8
11
>> x/3
ans =
Columns 1 through 4
-3.3333
-2.3333
-1.3333
-0.3333
Columns 5 through 8

0.6667
1.6667
2.6667
>> rem (x,3)
ans =
Columns 1 through 7
-1
-1
-1
-1
2
Column 8
2

3.6667

4. Use el vector del problema 3 y encuentre ex.


>> exp(x)
ans =
1.0e+004 *
Columns 1 through 4
0.0000
0.0000
Columns 5 through 8
0.0007
0.0148

0.0000

0.0000

0.2981

5.9874

5. Use el vector del problema 3.


a. Encuentre ln(x) (el logaritmo natural de x).
b. Encuentre log10(x) (el logaritmo comn de x).
Explique sus resultados.
>> log(x)
ans =
Columns
2.3026
Columns
1.3863
Columns
0.6931
Columns
2.0794

1
+
3
+
5

through 2
3.1416i
1.9459 + 3.1416i
through 4
3.1416i
0 + 3.1416i
through 6
1.6094
7 through 8
2.3979

>> log10(x)
ans =
Columns 1
1.0000 +
Columns 3
0.6021 +
Columns 5
0.3010
Columns 7
0.9031

through 2
1.3644i
0.8451 + 1.3644i
through 4
1.3644i
0 + 1.3644i
through 6
0.6990
through 8
1.0414

6. Use la funcin sign para determinar cules de los elementos en el vector x son
positivos.
>> sign(x)
ans =
Columns 1 through 7

-1
-1
-1
-1
1
1
1
Column 8
1
7. Cambie el format a rat y muestre el valor del vector x dividido entre 2.
>> format rat
>> x/2
ans =
Columns 1 through
-5
Columns 3 through
-2
Columns 5 through
1
Columns 7 through
4

2
-7/2

-1/2

6
8

5/2
11/2

Ejercicio de prctica 3.3


1. Factorice el nmero 322.
factor(322)
ans =
Columns 1 through 2
2
7
Column 3
23
2. Encuentre el mximo comn denominador de 322 y 6.
>> gcd(322,6)
ans =
2
3. 322 es nmero primo?
>> isprime(322)
ans =
0
4. Cuntos primos existen entre 0 y 322?
>> length(primes(322))
ans =
66
5. Aproxime p como nmero racional.
rats(pi)
ans =
355/113
6. Encuentre 10! (10 factorial).

Ejercicio de prctica 3.4


Calcule lo siguiente (recuerde que la notacin matemtica no necesariamente es la misma
que la notacin MATLAB):
1. sen(2u) para u = 3p.
>>

theta=3*pi;

sin(2*theta)
ans =
-1/1360936612766281
2. cos(u) para 0 u 2p; sea u que cambia en pasos de 0.2p.
>> theta=0:0.2*pi:2*pi;
>> cos(theta)
ans =
Columns 1 through 2
1

1292/1597

Columns 3 through 4
305/987

-305/987

Columns 5 through 6
-1292/1597

-1

Columns 7 through 8
-1292/1597

-305/987

Columns 9 through 10
305/987

1292/1597

Column 11
1

3. sen21(1).
>> asin(1)
ans =
355/226
4. cos21(x) para 21 x 1; sea x que cambia en pasos de 0.2.
>> acos(x)
ans =

Column 1
355/113
- 883/295i
Column 2
355/113
- 1957/743i
Column 3
355/113
- 1789/867i
Column 4
355/113
Column 5
0
+ 831/631i
Column 6
0
+ 1121/489i
Column 7
0
+ 371/134i
Column 8
0
+ 868/281i
5. Encuentre el coseno de 45.
>> cos(45*pi/180)
ans =
985/1393
a. Convierta el ngulo de grados a radianes y luego use la
funcin cos.
>> cos(45*pi/180)
ans =
985/1393
b. Use la funcin cosd.
>> cosd(45)
ans =
985/1393
6. Encuentre el ngulo cuyo seno es 0.5. Su respuesta est en grados o radianes?
>> asin(0.5)
ans =
355/678
>> asind(0.5)
ans =
30
7. Encuentre la cosecante de 60 grados. Es posible que tenga que usar la funcin help
para encontrar la sintaxis adecuada.
>> csc(60*pi/180)
ans =
1351/1170
>> cscd(60)
ans =
1351/1170

Ejercicio de prctica 3.5


Considere la siguiente matriz:

x=[4 90 85 75; 2 55 65 75; 3 78 82 79;1 84 92 93]


x =
Columns 1 through 2
4
90
2
55
3
78
1
84
Columns 3 through 4
85
75
65
75
82
79
92
93
1. Cul es el valor mximo en cada columna?
>> max(x)
ans =
Columns 1 through 2
4
90
Columns 3 through 4
92
93
2. En cul fila se presenta dicho mximo?
>> [maximum, row]=max(x)
maximum =
Columns 1 through 2
4
90
Columns 3 through 4
92
93
row =
Columns 1 through 2
1
1
Columns 3 through 4
4
4
3. Cul es el valor mximo en cada fila? (Tendr que transponer la matriz para
responder esta pregunta.)
>> max(x')
ans =
Columns 1 through 2
90
75
Columns 3 through 4
82
93

4. En cul columna ocurre el mximo?


>> [maximum, column]=max(x')
maximum =
Columns 1 through 2
90
75
Columns 3 through 4
82
93
column =
Columns 1 through 2
2
4
Columns 3 through 4
3
4
5. Cul es el valor mximo en toda la tabla?
>> max(max(x))
ans =
93

Ejercicio de prctica

3.6

Considere la siguiente matriz:

>> x = [4 90 85 75; 2 55 65 75; 3 78 82 79;


1. Cul es el valor medio en cada columna?
>> mean(x)
ans =
Columns 1 through 2
5/2
307/4
Columns 3 through 4
81
161/2
2. Cul es la mediana para cada columna?
>> median(x)
ans =
Columns 1 through 2
5/2
81
Columns 3 through 4
167/2
77
3. Cul es el valor medio en cada fila?
>> mean(x')
ans =
Columns 1 through 2
127/2
197/4
Columns 3 through 4
121/2
135/2
4. Cul es la mediana para cada fila? Cul es la mediana para toda la matriz?
>> median(x')
ans =
Columns 1 through 2
80
60
Columns 3 through 4
157/2
88

Ejercicio de prctica 3.7


Considere la siguiente matriz:

>> x = [4 90 85 75; 2 55 65 75; 3 78 82 79;1 84 92 93];


1. Use la funcin size para determinar el nmero de filas y columna en esta matriz.
>> size(x)
ans =
4
4
2. Use la funcin sort para ordenar cada columna en orden ascendente.
>> sort(x)
ans =
Columns 1 through 2
1
55
2
78
3
84
4
90
Columns 3 through 4
65
75
82
75
85
79
92
93
3. Use la funcin sort para ordenar cada columna en orden descendente.
>> sort(x,'descend')
ans =
Columns 1 through 2
4
90
3
84
2
78
1
55
Columns 3 through 4
92
93
85
79
82
75
65
75
4. Use la funcin sortrows para ordenar la matriz de modo que la primera columna est
en orden ascendente, pero cada fila todava conserve sus datos originales. Su matriz se
debe parecer a sta:

>> sortrows(x)
ans =
Columns 1 through 2
1
84
2
55
3
78
4
90
Columns 3 through 4
92
93
65
75
82
79
85
75

Ejercicio de prctica 3.8


Considere la siguiente matriz:
x = [4 90 85 75; 2 55 65 75; 3 78 82 79;1 84 92
93];
1. Encuentre la desviacin estndar para cada columna.
>> std(x)

ans =
Columns 1 through 2
1921/1488
5265/344
Columns 3 through 4
3014/263
1068/125
2. Encuentre la varianza para cada columna.
>> var(x)
ans =
Columns 1 through 2
507/6088
93/1094
Columns 3 through 4
341/4225
119/1469
Column 5
129/1972
3. Calcule la raz cuadrada de la varianza que encontr para cada columna.
>> sqrt(var(x))
ans =
Columns 1 through 2
187/648
235/806
Columns 3 through 4
777/2735
816/2867
Column 5
122/477
4. Cmo se comparan los resultados del problema 3 contra la desviacin estndar que
encontr en el problema 1?
Comparando la raz cuadrada de la varianza es igual a la
desviacin estndar

Ejercicio de prctica 3.9


1. Cree una matriz 3 x 3 de nmeros aleatorios distribuidos de manera pareja.
>> rand(3)
ans =
Columns 1 through 2
1535/2401
725/1333
6706/12311
579/803
301/465
511/978
Column 3
1105/1112
466/2131
385/3639
2. Cree una matriz 3 x 3 de nmeros aleatorios distribuidos de manera normal.
>> randn(3)
ans =
Columns 1 through 2
-1273/1116
-109/647
-1429/1307
-915/4187
-1414/3261
1290/2383
Column 3
573/1472
764/1017
1652/929
3. Cree una matriz 100 x 5 de nmeros aleatorios distribuidos de manera pareja.
Asegrese de suprimir la salida.
>> x=rand(100,5);
4. Encuentre el mximo, la desviacin estndar, la varianza y la media para cada
columna en la matriz que cre en el problema 3.
>> max(x)
ans =
Columns 1 through 2
197/199
1966/1967
Columns 3 through 4
2375/2386
737/746
Column 5
998/1001
>> std(x)
ans =
Columns 1 through 2
103/376
370/1229
Columns 3 through 4
82/277
586/2223
Column 5
499/1734
>> var(x)
ans =
Columns 1 through 2
411/5477
211/2328

Columns 3 through 4
659/7520
238/3425
Column 5
93/1123
>> mean(x)
ans =
Columns 1 through 2
573/1078
3261/6944
Columns 3 through 4
1060/2289
85/198
Column 5
583/1151
5. Cree una matriz 100 3 5 de nmeros aleatorios distribuidos de manera normal.
Asegrese de suprimir la salida.
>> x=randn(100,5);
6. Encuentre el mximo, la desviacin estndar, la varianza y la media para cada
columna en la matriz que cre en el problema 5.
>> max(x)
ans =
Columns 1 through 2
1346/489
811/275
Columns 3 through 4
800/293
999/410
Column 5
2766/1165
>> std(x)
ans =
Columns 1 through 2
1133/1035
513/505
Columns 3 through 4
1286/1321
821/920
Column 5
1861/1842
>> var(x)
ans =
Columns 1 through 2
1154/963
1648/1597
Columns 3 through 4
5383/5680
2233/2804
Column 5
1969/1929
>> mean(x)
ans =
Columns 1 through 2
187/2264
115/2177
Columns 3 through 4
214/643
95/8034
Column 5
-849/5396

7. Explique por qu son diferentes sus resultados para los


problemas 4 y 6.

Ejercicio de prctica 3.10


1. Cree los siguientes nmeros complejos:

>> A=1+i
A =
1
+
1i
>> B=2-3i
B =
2
3i
>> C=8+2i
C =
8
+
2i
2. Cree un vector D de nmeros complejos cuyos componentes
reales son 2, 4 y 6 y cuyos componentes imaginarios son 23,
8 y 216.
>> imagD=[-3,8,-16];
>> realD=[2,4,6];
>> D=complex(realD,imagD)
D =
Column 1
2
3i
Column 2
4
+
8i
Column 3
6
16i
3. Encuentre la magnitud (valor absoluto) de cada uno de los
vectores que cre en los problemas 1 y 2.
>> abs(A)
ans =
1393/985
>> abs(B)
ans =
4936/1369
>> abs(C)
ans =
2177/264
>> abs(D)
ans =
Columns 1 through 2
4936/1369
2889/323
Column 3
2136/125
4. Encuentre el ngulo desde la horizontal de cada uno de los
nmeros complejos que cre en los problemas 1 y 2.
>> angle(A)
ans =
355/452
>> angle(B)

ans =
-971/988
>> angle(C)
ans =
805/3286
>> angle(D)
ans =
Columns 1 through 2
-971/988
6737/6085
Column 3
-383/316
5. Encuentre la conjugada compleja del vector D.
>> conj(D)
ans =
Column 1
2
+
3i
Column 2
4
8i
Column 3
6
+
16i
6. Use el operador transpuesto para encontrar la conjugada
compleja del vector D.
>> D'
ans =
2
+
3i
4
8i
6
+
16i
7. Multiplique A por su conjugada compleja y luego saque la
raz cuadrada de su respuesta. Cmo se compara este valor
contra la magnitud (valor absoluto) de A?
>> sqrt(A.*A')
ans =
1393/985

Ejercicio de prctica 3.11


1. Use la funcin clock para agregar la hora y fecha a
hoja de trabajo.
>> clock
ans =
Columns 1 through 2
2016
9
Columns 3 through 4
20
6
Columns 5 through 6
5
2649/200
2. Use la funcin date para agregar la fecha a su hoja
trabajo.
>> date
ans =
20-Sep-2016
3. Convierta los siguientes clculos a cdigo MATLAB
explique sus resultados:
a. 322!(recuerde que ! significa factorial para
matemtico.)
b. 5 x 10500
>> 5*10^500
ans =
1/0
c. 1/5 x 10500
>> 1/5*10^500
ans =
1/0
d. 0/0
>> 0/0
ans =
0/0

su

de

y
un

Ejercicio de prctica 4.1


Cree variables MATLAB para representar las siguientes matrices y
selas en los ejercicios que siguen:

>> a = [12 17 3 6]
a =
Columns 1 through 2
12
17
Columns 3 through 4
3
6
>> b = [5 8 3; 1 2 3; 2 4 6]
b =
Columns 1 through 2
5
8
1
2
2
4
Column 3
3
3
6
>> c = [22;17;4]
c =
22
17
4
1. Asigne a la variable x1 el valor en la segunda
columna de la matriz a. En ocasiones, esto se
representa en los libros de matemticas como el
elemento a1,2 y se podra expresar como x1 = a1,2.
>> x1 = a(1,2)
x1 =
17
2. Asigne a la variable x2 la tercera columna de la
matriz b.
>> x2 = b(:,3)
x2 =
3
3
6
3. Asigne a la variable x3 la tercera fila de la matriz
b
>> x3 = b(3,:)
x3 =
Columns 1 through 2
2
4
Column 3
6

4. Asigne a la variable x4 los valores en la matriz b a


lo largo de la diagonal (es decir: elementos b1,1, b2,2
y b2,3).
>> x4 = [b(1,1), b(2,2), b(3,3)
x4 =
Columns 1 through 2
5
2
Column 3
6
5. Asigne a la variable x5 los primeros tres valores en
la matriz a como la primera fila y todos los valores
en la matriz b como la segunda a la cuarta filas.
>> x5 = [a(1:3);b]
x5 =
Columns 1 through 2
12
17
5
8
1
2
2
4
Column 3
3
3
3
6
6. Asigne a la variable x6 los valores en la matriz c
como la primera columna, los valores en la matriz b
como las columnas 2, 3 y 4, y los valores en la
matriz a como la ltima fila.
>> x6 = [c,b;a]
x6 =
Columns 1 through 2
22
5
17
1
4
2
12
17
Columns 3 through 4
8
3
2
3
4
6
3
6
7. Asigne a la variable x7 el valor del elemento 8 en
la matriz b, use el esquema de identificacin de
nmero de ndice sencillo.
>> x7=b(8)
x7 =
3
8. Convierta la matriz b en un vector columna llamado
x8.
x8=b(:)
x8 =

5
1
2
8
2
4
3
3
6

Ejercicio de prctica 4.2


1. El rea de un rectngulo es longitud por ancho (rea =
longitud 3 ancho).
Encuentre las reas de los rectngulos con longitudes de 1, 3
y 5 cm y con anchos de 2, 4, 6 y 8 cm. (Debe tener 12
respuestas.)
>> length = [1, 3, 5];
>> width = [2,4,6,8];
>> [L,W]=meshgrid(length,width);
>> area = L.*W
area =
Columns 1 through 2
2
6
4
12
6
18
8
24
Column 3
10
20
30
40
2. El volumen de un cilindro es volumen = pr2h. Encuentre el
volumen de los contenedores cilndricos con radios desde 0
hasta 12 m y alturas desde 10 hasta 20 m. Aumente la
dimensin del radio por 3 metros y la altura por 2 metros
conforme abarca los dos rangos.

>> radius = 0:3:12;


>> height = 10:2:20;
>> [R,H] = meshgrid(radius,height);
>> volume = pi*R.^2.*H
volume =
Columns 1 through 2
0
11027/39
0
38340/113
0
27313/69
0
59263/131
0
65653/129
0
20923/37
Columns 3 through 4
42977/38
33081/13
169646/125
131306/43
17417/11
106877/30
110383/61
500795/123

246326/121
42977/19
Column 5
126669/28
331149/61
69668/11
94097/13
*
126669/14

41224/9
106877/21

Ejercicio de prctica
1. Cree una matriz 3 x
>> zeros(3)
ans =
Columns 1 through
0
0
0
Column 3
0
0
0
2. Cree una matriz 3 x
>> zeros(3,4)
ans =
Columns 1 through
0
0
0
Columns 3 through
0
0
0
3. Cree una matriz 3 x
>> ones(3)
ans =
Columns 1 through
1
1
1

4.3
3 de ceros.
2

0
0
0

4 de ceros.
2

0
0
0

0
0
0
3 de unos.
2

1
1
1

Column 3
1
1
1
4. Cree una matriz 5 x 3 de unos.
>> ones(5,3)
ans =
Columns 1 through 2
1
1
1
1
1
1
1
1
1
1
Column 3
1
1
1
1
1

5. Cree una matriz 4 x 6 en la que todos los elementos tengan un


valor de pi.
>> ones(4,6)*pi
ans =
Columns 1 through 2
355/113
355/113
355/113
355/113
355/113
355/113
355/113
355/113
Columns 3 through 4
355/113
355/113
355/113
355/113
355/113
355/113
355/113
355/113
Columns 5 through 6
355/113
355/113
355/113
355/113
355/113
355/113
355/113
355/113
6. Use la funcin diag para crear una matriz cuya diagonal tenga
valores de 1, 2, 3.
>> x = [1,2,3];
>> diag(x)
ans =
Columns 1 through 2
1
0
0
2
0
0
Column 3
0
0
3
7. Cree una matriz mgica 10 x 10.
>> x = magic(10)
x =
Columns 1 through 2
92
99
98
80
4
81
85
87
86
93
17
24
23
5
79
6
10
12
11
18
Columns 3 through 4
1
8
7
14
88
20
19
21

25
2
76
83
82
89
13
95
94
96
100
77
Columns 5 through 6
15
67
16
73
22
54
3
60
9
61
90
42
91
48
97
29
78
35
84
36
Columns 7 through
74
51
55
57
56
63
62
69
68
75
49
26
30
32
31
38
37
44
43
50
Columns 9 through 10
58
40
64
41
70
47
71
28
52
34
33
65
39
66
45
72
46
53
27
59
a. Extraiga la diagonal de esta matriz.
>> diag(x)
ans =
92
80
88
21
9
42
30
38
46
59

b. Extraiga la diagonal que corre de inferior izquierda a


superior derecha de esta matriz.
>> diag(fliplr(x))
ans =
40
64
63
62
61
90
89
13
12
11
c. Confirme que la suma de las filas, columnas y diagonales
son todas iguales.
>> sum(x)
ans =
Columns 1 through 2
505
505
Columns 3 through 4
505
505
Columns 5 through 6
505
505
Columns 7 through 8
505
505
Columns 9 through 10
505
505
>> sum(x')
ans =
Columns 1 through 2
505
505
Columns 3 through 4
505
505
Columns 5 through 6
505
505
Columns 7 through 8
505
505
Columns 9 through 10
505
505
>> sum(diag(x))
ans =
505
>> sum(diag(fliplr(x)))
ans =
505

Ejercicio de prctica 5.1


1. Grafique x contra y para y = sen(x). Sea x que vara desde 0
hasta 2p en incrementos de 0.1p.
>> x=0:0.1*pi:2*pi;
>> y=sin(x);
>> plot(x,y)

2. Agregue un ttulo y etiquete su grfica.


>> title('Curva sinusoidal')
>> xlabel('valores x')
>> ylabel('sen(x)')

3. Grafique x contra y1 y y2 para y1 = sen(x) y y2 = cos(x). Sea x


que vara desde 0 hasta 2p enincrementos de 0.1p. Agregue un
ttulo y etiquete su grfica.
>> figure(2)
>> y1=sin(x);
>> y2=cos(x);
>> plot(x,y1,x,y2)
>> title('Grficas seno y coseno')
>> xlabel('valores x')
>> ylabel('valores y')

4. Vuelva a crear la grfica de la parte 3, pero haga la lnea


sen(x) rayada y roja.
Haga la lnea cos(x) verde y punteada.
>> figure(3)
>> plot(x,y1,'-- r',x,y2,': g')
>> title('Grficas seno y coseno')
>> xlabel('valores x')
>> ylabel('valores y')

5. Agregue una leyenda a la grfica de la parte 4.


>> legend('sen(x)','cos(x)')

6. Ajuste los ejes de modo que el eje x vaya de 21 a 2p + 1 y el


eje y de 21.5 a
+1.5.
>> axis([-1,2*pi+1,-1.5,1.5])

7. Cree un nuevo vector, a = cos(x). Sea x que vara desde 0 hasta


2p en incrementos de 0.1p. Grafique slo a (plot(a)) y observe
el resultado. Compare este resultado con la grfica que se
produce al graficar x contra a (plot(x,a)).
>> axis([-1,2*pi+1,-1.5,1.5])
>> figure(4)
>> a=cos(x);
>> plot(a)

Ejercicio de prctica 5.2


1. Subdivida una ventana de figura en dos filas y una columna.
subplot(2,1,1)
2. En la ventana superior, grafique y = tan(x) para -1.5
1.5. Use un incremento de 0.1.
>> x=-1.5:0.1:1.5;
>> y=tan(x);
>> plot(x,y)

3. Agregue un ttulo y etiquetas de eje a su grfica.


>> title('Tangente(x)')
>> xlabel('valor x')
>> ylabel('valor y')

4. En la ventana inferior, grafique y = senh(x) para el mismo


rango.
>> subplot(2,1,2)
>> y=sinh(x);
>> plot(x,y)

5. Agregue un ttulo y etiquetas a su grfica.


>> title('Seno hiperblico de x')
>> xlabel('valor x')
>> ylabel('valor y')

6. Intente de nuevo los ejercicios anteriores, pero divida


ventana de figura verticalmente en lugar de horizontalmente.
>> figure(2)
>> subplot(1,2,1)
>> plot(x,y)
>> title('Tangente(x)')
>> xlabel('valor x')
>> ylabel('valor y')
>> subplot(1,2,2)
>> y=sinh(x);
>> plot(x,y)
>> title('Seno hiperblico de x')
>> xlabel('valor x')
>> ylabel('valor y')

la

Ejercicio de prctica 5.3


1. Defina un arreglo llamado theta, desde 0 hasta 2p, en pasos
de 0.01p.
Defina un arreglo de distancias r = 5*cos(4*theta).
Elabore una grfica polar de theta contra r.

>> theta = 0:0.01*pi:2*pi;


>> r = 5*cos(4*theta);
>> polar(theta,r)

2. Use el comando hold on para congelar la grfica.


Asigne r = 4*cos(6*theta) y grafique.
Agregue un ttulo

>>
>>
>>
>>

hold on
r=4*cos(6*theta);
polar(theta,r)
title('Poder floral')

3. Cree una nueva figura.


Use el arreglo theta de los problemas anteriores.
Asigne r = 5 5*sin(theta)
y cree una nueva grfica polar.

>> figure(2)
>> r=5-5*sin(theta);
>> polar(theta,r)

4. Cree una nueva figura.


Use el arreglo theta de los
problemas anteriores.
Asigne r = sqrt(5^2*cos(2*theta))
y cree una nueva grfica polar.

5. Cree una nueva figura.


Defina un arreglo theta tal que
theta = pi/2:4/5*pi:4.8*pi;
Cree un arreglo de seis miembros
de unos llamado r.
Cree una nueva grfica polar
de theta contra r.

>>
>>
>>
>>

figure(4)
theta = pi/2:4/5*pi:4.8*pi;
r=ones(1,6);
polar(theta,r)

Ejercicio de prctica 5.4


Cree arreglos x y y adecuados para usar en grfica cada una
de las expresiones que siguen. Use el comando subplot para
dividir sus figuras en cuatro secciones y cree cada una de
estas cuatro grficas para cada expresin:
Rectangular
Semilogx
Semilogy
loglog

Usualmente, los datos fsicos se grafican de modo que caen en


una lnea recta. Cul de los tipos de grficas precedentes
resultan en una lnea recta para cada problema?
>> figure(1)
>> x=-1:0.1:1;
>> y=5*x+3;
>> subplot(2,2,1)
>> plot(x,y)
>> title('Coordenadas rectangulares')
>> ylabel('eje y')
>> grid on
>> subplot(2,2,2)
>> semilogx(x,y)
Warning: Negative data ignored
Warning: Negative data ignored
>> title('Sistema coordenado semilog x')
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored
>> subplot(2,2,3)
>> semilogy(x,y)
Warning: Negative data ignored
>> title('Sistema coordenado semilog y')
Warning: Negative data ignored
>> ylabel('eje y')
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
>> xlabel('eje x')
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored
>> subplot(2,2,4)
>> loglog(x,y)

Warning: Negative data ignored


Warning: Negative data ignored
>> title('Grfica log')
Warning: Negative data ignored
Warning: Negative data ignored
>> xlabel('eje x')
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored
Warning: Negative data ignored

>> figure(2)
>> x=-1:0.1:1;
>> y=3*x.^2;
>> subplot(2,2,1)
>> plot(x,y)
>> title('Coordenadas rectangulares')
>> ylabel('eje y')
>> grid on
>> subplot(2,2,2)
>> semilogx(x,y)
Warning: Negative data ignored
Warning: Negative data ignored
>> title('Sistema coordenado semilog x')
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored
>> subplot(2,2,3)

>> semilogy(x,y)
>> title('Sistema coordenado semilog y')
>> ylabel('eje y')
Warning: Negative data ignored
>> xlabel('eje x')
Warning: Negative data ignored
>> grid on
>> subplot(2,2,4)
>> loglog(x,y)
Warning: Negative data ignored
>> title('Grfica log')
Warning: Negative data ignored
>> xlabel('eje x')
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored

>> figure(3)
>> x=-1:0.1:1;
>> y=12*exp(x+2);
>> subplot(2,2,1)
>> plot(x,y)
>> title('Coordenadas rectangulares')
>> ylabel('eje y')
>> grid on
>> subplot(2,2,2)
>> semilogx(x,y)
Warning: Negative data ignored
Warning: Negative data ignored
>> title('Sistema coordenado semilog x')
Warning: Negative data ignored

>> grid on
Warning: Negative data ignored
>> subplot(2,2,3)
>> semilogy(x,y)
>> title('Sistema coordenado semilog y')
>> ylabel('eje y')
>> xlabel('eje x')
Warning: Negative data ignored
>> grid on
>> subplot(2,2,4)
>> loglog(x,y)
Warning: Negative data ignored
>> title('Grfica Log')
Warning: Negative data ignored
>> xlabel('eje x')
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored

>>
>>
>>
>>
>>
>>
>>

figure(4)
x=-1:0.01:1;
y=1./x;
subplot(2,2,1)
plot(x,y)
title('Coordenadas rectangulares')
ylabel('eje y')

>> grid on
>> subplot(2,2,2)
>> semilogx(x,y)
Warning: Negative data ignored
Warning: Negative data ignored
>> title('Sistema coordenado semilog x')
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored
>> subplot(2,2,3)
>> semilogy(x,y)
Warning: Negative data ignored
>> title('Sistema coordenado semilog y')
Warning: Negative data ignored
>> ylabel('eje y')
Warning: Negative data ignored
>> xlabel('eje x')
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored
>> subplot(2,2,4)
>> loglog(x,y)
Warning: Negative data ignored
Warning: Negative data ignored
>> title('Grfica Log')
Warning: Negative data ignored
Warning: Negative data ignored
>> xlabel('eje x')
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
Warning: Negative data ignored
>> grid on
Warning: Negative data ignored
Warning: Negative data ignored

Ejercicio de prctica 5.5


Cree una grfica de las funciones que siguen. Necesitar
seleccionar un rango apropiado para cada grfica. No olvide
poner ttulo y etiquetas a sus grficas.

1.

>>
>>
>>
>>

fplot('5*t^2',[-3,+3])
title('5*t^2')
xlabel('eje x')
ylabel('eje y')

2.

>> fplot('t*exp(t)',[0,10])
>> title('t*exp(t)')
>> xlabel('eje x')
>> ylabel('eje y')

Ejercicio de prctica 6.1


Cree funciones MATLAB para evaluar las siguientes funciones matemticas
(asegrese de seleccionar nombres de funcin significativos):
8.

y=( x )=x 2
function output = quad(x)
output = x.^2;

9.

y ( x ) =e1 / x
function output=one_over(x)
output = exp(1./x);

10. y ( x ) =sen ( x 2 )
function output = sin_x_squared(x)
output = sin(x.^2);

Cree funciones MATLAB para las siguientes conversiones de unidades (es


posible que necesite consultar un manual o Internet para los factores de
conversin adecuados):
11.Pulgadas a pies
function result = in_to_ft(x)
result = x./12;

12.Caloras a joules
function result=cal_to_joules(x)
result = 4.2.*x;

13.Watts a BTU/h
function output = Watts_to_Btu_per_hour(x)
output = x.*3.412;

14.Metros a millas
function output = meters_to_miles(x)
output = x./1000.*.6214;

15.Millas por hoa(mph) a pies/s


function output = mph_to_fps(x)
output = x.*5280/3600;

Ejercicio de prctica 6.2


Si supone que las dimensiones de la matriz concuerdan, cree y ponga a prueba
funciones MATLAB para evaluar las siguientes funciones matemticas simples
con vectores de entrada mltiple y un vector de salida sencilla:
16. z ( x , y )=x+ y
function output = z1(x,y)
% suma de x y y
% las dimensiones de la matriz deben concordar
output = x+y;

17. z ( a ,b ,c ) =a bc
function output = z2(a,b,c)
% encuentra a.*b.^c
% las dimensiones de la matriz deben concordar
output = a.*b.^c;

18. z ( w , x , y )=w e y
function output = z3(w,x,y)
% encuentra w.*exp(x./y)
% las dimensiones de la matriz deben concordar
output = w.*exp(x./y);

19. z ( p , t ) =p /sen ( t )
function output = z4(p,t)
% encuentra p./sin(t)
% las dimensiones de la matriz deben concordar
output = p./sin(t);

Si supone que las dimensiones de la matriz concuerdan, cree y ponga a prueba


funciones MATLAB para evaluar las siguientes funciones matemticas simples
con un vector de entrada sencilla y vectores de salida mltiple:
20. f ( x )=cos ( x )

f ( x )=sen ( x )
function [a,b]=f5(x)
a = cos(x);
b = sin(x);

21. f ( x )=5 x 2+ 2

f ( x )= 5 x 2+2
function [a,b] = f6(x)
a = 5.*x.^2 + 2;
b = sqrt(5.*x.^2 + 2);

22. f ( x )=exp ( x )

f ( x )=( x )
function [a,b] = f7(x)
a = exp(x);
b = log(x);

Si supone que las dimensiones de la matriz concuerdan, cree y ponga a


prueba funciones MATLAB para evaluar las siguientes funciones

matemticas simples con vectores de entrada mltiple y vectores de


salida mltiple:
23. f ( x , y ) =x+ y

f ( x , y ) =x y
function [a,b] = f8(x,y)
a = x+y;
b = x-y;

24.

f ( x , y ) = y ex
f ( x , y ) =x e y
function [a,b] = f9(x,y)
a = y.*exp(x);

b = x.*exp(y);

Ejercicio de prctic a 7.1


25.Cree un archivo-m para calcular el rea A de un tringulo:

A=

1
2

Base altura

b = input('Ingrese la longitud de la base del


tringulo: ');
h = input('Ingrese la altura del tringulo: ');
Area = 1/2*b*h

Enter the length of the base of the triangle: 5


Enter the height of the triangle: 4
Area =
10

Conmine al usuario a ingresar los valores para la base y la altura.


26. Cree un archivo-m para encontrar el volumen V de un cilindro circular
recto:

V = r 2 h
r = input('Ingrese el radio del cilindro: ');
h = input('Ingrese la altura del cilindro: ');
Volume = pi*r.^2*h
Conmine al usuario a ingresar los valores de r y h.
Enter the radius of the cylinder: 2
Enter the height of the cylinder: 3
Volume =
37.6991

27.Cree un vector desde 1 hasta n, y permita al usuario ingresar el valor de n.


n = input('Ingrese un valor de n: ')
vector = 0:n
Enter a value of n: 3
n=
3
vector =
0123
28. Cree un vector que comience en a, termine en b y tenga un espaciamiento
de c.
Permita al usuario ingresar todos estos parmetros.
a = input('Ingrese el valor inicial: ');
b = input('Ingrese el valor final: ');
c = input('Ingrese el espaciamiento del vector: ');
vector = a:c:b
Enter the starting value: 0
Enter the ending value: 6
Enter the vector spacing: 2
vector =
0246

Ejercicio de prctic a 7.1


29.Cree un archivo-m para calcular el rea A de un tringulo:

A=

1
2

Base altura

b = input('Ingrese la longitud de la base del


tringulo: ');
h = input('Ingrese la altura del tringulo: ');
Area = 1/2*b*h

Enter the length of the base of the triangle: 5


Enter the height of the triangle: 4
Area =
10

Conmine al usuario a ingresar los valores para la base y la altura.


30. Cree un archivo-m para encontrar el volumen V de un cilindro circular
recto:

V = r 2 h
r = input('Ingrese el radio del cilindro: ');
h = input('Ingrese la altura del cilindro: ');
Volume = pi*r.^2*h
Conmine al usuario a ingresar los valores de r y h.
Enter the radius of the cylinder: 2
Enter the height of the cylinder: 3
Volume =
37.6991

31.Cree un vector desde 1 hasta n, y permita al usuario ingresar el valor de n.


n = input('Ingrese un valor de n: ')
vector = 0:n
Enter a value of n: 3
n=
3
vector =
0123
32. Cree un vector que comience en a, termine en b y tenga un espaciamiento
de c.
Permita al usuario ingresar todos estos parmetros.
a = input('Ingrese el valor inicial: ');
b = input('Ingrese el valor final: ');
c = input('Ingrese el espaciamiento del vector: ');
vector = a:c:b
Enter the starting value: 0
Enter the ending value: 6
Enter the vector spacing: 2
vector =
0246

Ejercicio de prctica 7.2


En un archivo-m
33.Use el comando disp para crear un ttulo para una tabla que convierte
pulgadas a pies.
disp('Tabla de conversin de pulgadas a pies')
34.Use el comando disp para crear encabezados de columna para su tabla.
disp(' Pulgadas Pies')

35.Cree un vector inches desde 0 hasta 120 con un incremento de 10.


inches = 0:10:120;
Calcule los correspondientes valores de feet.
feet = inches./12;
Agrupe el vector inch y el vector feet en una matriz table.
table = [inches; feet];
Use el comando fprintf para enviar su tabla a la ventana de comandos.
Tabla de conversin de pulgadas a pies
Pulgadas

Pies

0.00

10

0.83

20

1.67

30

2.50

40

3.33

50

4.17

60

5.00

70

5.83

80
90

6.67
7.50

100

8.33

110

9.17

120

10.00

Вам также может понравиться