Você está na página 1de 84

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. >> 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
b. >> 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
c. >> 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
xregcovariance/exp
Reference page in Help browser
doc exp
Ejercicio de prctica 3.2
1. Cree un vector x de -2 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 0
>> abs(x)
ans =
2 1 0

>> sqrt(x)
ans =
Columns 1 through 2
0 + 1.4142i
0 + 1.0000i
Columns 3 through 4
0
1.0000
Column 5
1.4142
1. 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
2. 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 3.6667
>> rem (x,3)
ans =
Columns 1 through 7
-1 -1 -1 -1 2 2 2
Column 8
2
3. Use el vector del problema 3 y encuentre ex.
>> exp(x)
ans =
1.0e+004 *
Columns 1 through 4
0.0000 0.0000 0.0000 0.0000
Columns 5 through 8
0.0007 0.0148 0.2981 5.9874
4. 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 1 through 2
2.3026 + 3.1416i 1.9459 + 3.1416i
Columns 3 through 4
1.3863 + 3.1416i
0 + 3.1416i
Columns 5 through 6
0.6931
1.6094
Columns 7 through 8
2.0794
2.3979
>> log10(x)
ans =
Columns 1 through 2
1.0000 + 1.3644i 0.8451 + 1.3644i
Columns 3 through 4
0.6021 + 1.3644i
0 + 1.3644i
Columns 5 through 6
0.3010
0.6990
Columns 7 through 8
0.9031
1.0414

5. 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 2
-5
-7/2
Columns 3 through 4
-2
-1/2
Columns 5 through 6
1
5/2
Columns 7 through 8
4
11/2
Ejercicio de prctica 3.3
1. Factorice el nmero 322
>> Factor (322)
ans =
2 7 23
2. Encuentre el mximo comn denominador de 322 y 6.
>> gcd(322,6)
ans =
2
3. 322 es nmero primo?
>> primes(322)
ans =
0

4. Cuntos primos existen entre 0 y 322?


primos (0, 322)
ans =
66
1. Aproxime p como nmero racional.
rats(pi)
ans =
355/113
2. 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
1. 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
2. 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
3. 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
4. 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 84 92 93];
1. Cul es el valor medio en cada columna?
>> mean(x)
ans =
2.5000

76.7500

81.0000

80.5000

2. Cul es la mediana para cada columna?


>> median(x)
ans =
2.5000

81.0000

83.5000

77.0000

3. Cul es el valor medio en cada fila?

>> mean(x')
ans =
63.5000

49.2500

60.5000

67.5000

4. Cul es la mediana para cada fila? Cul es la mediana para toda la matriz?
>> median(x')
ans =
80.0000

60.0000

Ejercicio de prctica 3.7

78.5000

88.0000

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

2. Use la funcin sort para ordenar cada columna en orden ascendente.


>> sort(x)
ans =
1

55

65

75

78

82

75

84

85

79

90

92

93

3. Use la funcin sort para ordenar cada columna en orden descendente.


>> sort(x,'descend')
ans =
4
3
2
1

90
84
78
55

92
85
82
65

93
79
75
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 =
1
2
3
4

84
55
78
90

92
65
82
85

93
75
79
75

Ejercicio de prctica 3.8


Considere la siguiente matriz:

1. Encuentre la desviacin estndar para cada columna.


>> std(x)

ans =
1.2910

15.3052

11.4601

8.5440

2. Encuentre la varianza para cada columna.


>> var(x)
ans =
1.6667

234.2500

131.3333

73.0000

3. Calcule la raz cuadrada de la varianza que encontr para cada columna.


>> sqrt(var(x))
ans =
1.2910

15.3052

11.4601

8.5440

4. Cmo se comparan los resultados del problema 3 contra la desviacin


estndar que encontr en el problema 1?
Son resultados similares

Ejercicio de prctica 3.9

1. Cree una matriz 3 3 3 de nmeros aleatorios distribuidos de manera pareja.


>> rand(3)
ans =
0.8147

0.9134

0.2785

0.9058

0.6324

0.5469

0.1270

0.0975

0.9575

2. Cree una matriz 3 3 3 de nmeros aleatorios distribuidos de manera normal.


>>

randn(3)

ans =
2.7694

0.7254

-0.2050

-1.3499

-0.0631

-0.1241

3.0349

0.7147

1.4897

3. Cree una matriz 100 3 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 =
0.9961

0.9619

0.9880

0.9991

0.9937

0.2838

0.2843

0.2821

0.2579

>> std(x)
ans =
0.2854

>> var(x)
ans =
0.0814

0.0805

0.0808

0.0796

0.0665

>> mean(x)
ans =
0.5082

0.4658

0.5080

0.4754

0.4999

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 =
2.2272

2.5088

2.7891

2.6052

3.5267

>> std(x)
ans =
0.9283

0.9743

1.0061

0.9682

1.0162

>> var(x)
ans =
0.8618

0.9493

1.0123

0.9373

1.0326

-0.0908

-0.1185

-0.2511

0.1266

>> mean(x)
ans =
0.0815

7. Explique por qu son diferentes sus resultados para los problemas 4 y 6.


Porque en el caso 4 eran parejas de nmeros aleatorios distribuidos. Mientras que en el caso
6 eran parejas normales de nmeros aleatorios distribuidos lo que hace que sean resultados
diferentes.

Ejercicio de prctica 3.10


1. Cree los siguientes nmeros complejos

>> A=1+i
A =
1.1
+ 1.0000i
>> B=2-3i
B =
1.2

- 3.0000i
>> C=8+2i
C =
8.0000 + 2.0000i

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 =
2.0000 - 3.0000i
4.0000 + 8.0000i
6.0000 -16.0000i
3. Encuentre la magnitud (valor absoluto) de cada uno de los vectores que cre en
los problemas 1 y 2.
>> abs(A)
ans =
1.4142
>> abs(B)
ans =
3.6056
>> abs(C)

ans =
8.2462
>> abs(D)
ans =
3.6056
8.9443
17.0880
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 =
0.7854
>> angle(B)
ans =
-0.9828
>> angle(C)
ans =
0.2450
>> angle(D)
ans =
-0.9828

1.1071

-1.2120

5. Encuentre la conjugada compleja del vector D.


>> conj(D)
ans =
2.0000 + 3.0000i

4.0000 - 8.0000i

6.0000 +16.0000i

6. Use el operador transpuesto para encontrar la conjugada compleja del vector D.


>> D'

ans =
2.0000 + 3.0000i
4.0000 - 8.0000i
6.0000 +16.0000i
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 =
1.4142

Ejercicio de prctica 3.11


1. Use la funcin clock para agregar la hora y fecha a su 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 de trabajo.
>> date
ans =
20-Sep-2016
3. Convierta los siguientes clculos a cdigo MATLAB y explique sus
resultados:

a. 322! (recuerde que ! significa factorial para un 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
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
6.
4
a. 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 a 1,2 y se podra


expresar como x1 = a1,2.
>> x1 = a(1,2)
x1 =
17
b. Asigne a la variable x2 la tercera columna de la matriz b.
>> x2 = b(:,3)
x2 =
3
3
6
c. 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
d. 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
e. 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
f. 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
g. 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
h. 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


5. 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
6. 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
41224/9

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

106877/21

Ejercicio de prctica 4.3


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

Column 3
1
1
1
6. 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
7. 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
8. 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
9. 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

2. 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)')

2. 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')

3. 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')

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


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

4. 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])

5. 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


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

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


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

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


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

6 Agregue un ttulo y etiquetas a su grfica.


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

7 Intente de nuevo los ejercicios anteriores, pero divida la 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')

Ejercicio de prctica 5.3


c. 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)

d. 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')

e. 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)

f. 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.

g. Cree una nueva figura.


Defina un arreglo theta tal que heta = 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:
6.
7.
8.
9.

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.

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

6.

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

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
7.
4
i. 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
j. Asigne a la variable x2 la tercera columna de la matriz b.
>> x2 = b(:,3)
x2 =
3
3
6
k. 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
l. 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
m. 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
n. 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
o. 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
p. 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


7. 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
8. 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
41224/9
42977/19
106877/21
Column 5
126669/28
331149/61
69668/11
94097/13
*
126669/14
Ejercicio de prctica 4.3
10. Cree una matriz 3 x 3 de ceros.
>> zeros(3)
ans =
Columns 1 through 2
0
0
0
0
0
0
Column 3

0
0
0
11. Cree una matriz 3 x 4 de ceros.
>> zeros(3,4)
ans =
Columns 1 through 2
0
0
0
0
0
0
Columns 3 through 4
0
0
0
0
0
0
12. Cree una matriz 3 x 3 de unos.
>> ones(3)
ans =
Columns 1 through 2
1
1
1
1
1
1

Column 3
1
1
1
13. 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

14. 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
15. 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
16. 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


4. 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)')

2. 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')

3. 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)')

4. 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])

5. 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


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

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


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

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


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

12 Agregue un ttulo y etiquetas a su grfica.


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

13 Intente de nuevo los ejercicios anteriores, pero divida la 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')

Ejercicio de prctica 5.3


h. 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)

i.

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')

j.

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)

k. 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.

l.

Cree una nueva figura.


Defina un arreglo theta tal que heta = 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:
10. Rectangular
11. Semilogx
12. Semilogy
13. 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.

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

8.

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

Ejercicio de practica 6.1

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

2.

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

3.

( )

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

4.

( )

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):
5. Pulgadas a pies
function result = in_to_ft(x)
result = x./12;

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

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

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

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


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

Ejercicio de practica 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:

10. (

function output = z1(x,y)


% suma de x y y
% las dimensiones de la matriz deben concordar
output = x+y;

11. (

function output = z2(a,b,c)

% encuentra a.*b.^c
% las dimensiones de la matriz deben concordar
output = a.*b.^c;

12. (

function output = z3(w,x,y)


% encuentra w.*exp(x./y)
% las dimensiones de la matriz deben concordar
output = w.*exp(x./y);

13. (

( )

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:

14. ( )

( )
( )

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

15. ( )

( )

( )

function [a,b] = f6(x)


a = 5.*x.^2 + 2;
b = sqrt(5.*x.^2 + 2);

16. ( )

( )
( )

( )

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:
17. (

)
(

function [a,b] = f8(x,y)


a = x+y;
b = x-y;

18.

)
(

function [a,b] = f9(x,y)


a = y.*exp(x);
b = x.*exp(y);

Ejercicio de practica 7.1


19. Cree un archivo-m para calcular el rea A de un tringulo:
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.


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

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

21. 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
22. 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 practica 7.2


En un archivo-m

23. Use el comando disp para crear un ttulo para una tabla que convierte pulgadas a pies.
disp('Tabla de conversin de pulgadas a pies')
24. Use el comando disp para crear encabezados de columna para su tabla.
disp(' Pulgadas Pies')

25. 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

6.67

90

7.50

100

8.33

110

9.17
120

10.00

Você também pode gostar