Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Ejercicios Matlab 2 PDF
Ejercicios Matlab 2 PDF
Bibliografía:
César Pérez, Prentice Hall, 2002. “MATLAB y sus Aplicaciones en las Ciencias y la
Ingeniería”.
Los datos en Matlab pueden guardarse en ficheros .mat, estos ficheros son legibles
sólo por Matlab. También se pueden guardar en ficheros ASCII legibles por
cualquier aplicación. El comando save permite guardas datos en este tipo de
ficheros.
a) A = inv(rand(3))
b) B = inv(2*ones(3) – eye(3))
c) save matriz.asc A B –ascii
d) dir
e) type matriz.asc
f) clear
g) load matriz.asc
h) whos
i) matriz
j) A = matriz(1:3,1:3)
k) B = matriz(4:6,1:3)
a) type fclose.m;
b) fid = fopen(‘fclose.m’,’r’);
c) F = fread(fid);
1
d) S = char (F’)
e) Fid = fopen(‘id4.bin’,’w+’)
f) Fwrite(fid,eye(4),’integer*4’)
g) Fclose(valor de fid)
a) x = 0:.1:1;
b) y = [x; exp(x)];
c) fid = fopen(‘exponen.txt’, ‘w’);
d) fprintf(fid, ‘%6.2f %12.8f\n’, y);
e) fclose(valor de fid)
f) S = sprintf(‘Un numero aureo es %6.3f’, (1+sqrt(5))/2)
g) T = ‘2.7183 3.1416’;
h) A = sscanf(S, ‘%f’)
Hacer:
a) roots([2 11 12 –9])
b) solve(‘2*x^3+11*x^2+12*x-9’,’x’)
IV. Polinomios
p = [1 –6 –72 -27];
r = roots(p)
a = [3 6 9];
2
b = [1 2 0];
k = polyder(a,b)
[q,d] = polyder(b,a)
c) Consideremos la matriz:
⎡ 1 −1 3 ⎤
M = ⎢⎢− 1 i − 1 − 2i ⎥⎥
⎢⎣ i 1 i − 2 ⎥⎦
Hacer:
x = -2.9:0.2:2.9
bar(x, exp(-x.*x)
barh(x, exp(-x.*x)
b) y = randn(10000,1);
hist(y)
hist(y,20)
d) x = 0:0.05:10;
y = sin(x).*exp(-0.4*x);
plot(x,y)
e) t = 0:0.1:2*pi;
x = 4*cos(t) – cos(4*t);
y = 4*sin(t) – sin(4*t);
fplot(‘[sin(x), sin(2*x), sin(3*x)]’, [0,2*pi], ‘-‘,’o’,’*’);
legend(‘Sen(x)’, ‘Sen(2x)’, ‘Sen(3x)’)
g) x = 0:0.01:3;
y = abs(exp(-0.5*x).*sin(5*x));
subplot(2,2,1)
3
plot(x,y)
title(‘normal’)
hold on
subplot(2,2,2)
loglog(x,y)
title(‘logaritmica’)
subplot(2,2,3)
semilogx(x,y)
title(‘semilogaritmica en eje x’)
subplot(2,2,4)
semilogy(x,y)
title(‘semilogaritmica en eje y’)
V. Gráficos 3D
Hacer
a) t = 0:pi/50:10*pi;
plot3(sin(t), cos(t),t)
grid on
axis square
b) X = linspace(0,1,10);
Y = X./2;
Z = sin(X) + cos(Y);
stem3(X,Y,Z,’fill’)
sphere
axis equal
sen ( x 2 + y 2 )
z=
x 2 + y2
[x,y] = meshgrid(-7.5:.5:7.5);
z = sin(sqrt(x.^2+y.^2))./sqrt(x.^2+y.^2);
figure(1)
surf(x,y,z)
figure(2)
surfc(x,y,z)
figure(3)
contour(z)
figure(4)
contour3(z,50)