ejercicios resueltos Matlab

UNIVERSIDAD NACIONAL “HERMILIO VALDIZÁN MEDRANO” HUÁNUCO Facultad de Ingeniería Industrial y Sistemas E.A.P. Ingeniería

Views 246 Downloads 9 File size 4MB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

UNIVERSIDAD NACIONAL “HERMILIO VALDIZÁN MEDRANO” HUÁNUCO Facultad de Ingeniería Industrial y Sistemas E.A.P. Ingeniería Industrial MÉTODOS NUMÉRICOS.

Ing. CHAVEZ ESTRADA, Jorge.

 

SOLUCIONARIO DE 100 EJERCICIOS Tiburcio Gobea, Álvaro

2015

EJERCICIO 1 x01=[-1 -1 1 1]; y01=[0 1 1 0]; x02=[0 0.5 0 0.5 0 0 0 0.5 1 1]; y02=[1 0.5 0 0.5 1 2.25 1.5 1.25 1.25 1]; h=pi/10; t=0:h:2*pi; t01=0.5*sin(t)+1; t02=0.5*cos(t); t03=0.5*sin(t)-1; t04=0.5*cos(t); t05=0.25*sin(t); t06=0.25*cos(t)+2.5; plot(x01,y01,'linewidth',3,'color','k') axis([-2 2 -1 4]) grid on hold on plot (x02,y02,'linewidth',4) plot (t01,t02,'color','k','linewidth',3) plot (t03,t04,'color','k','linewidth',3) plot (t05,t06,'color','b','linewidth',3) colormap('spring') title('METODOS NUMERICOS FIIS UNHEVAL 2014 ,QUISPE ZEVALLOS, DEISY','color','b')

EJERCICIO 2 %ciclista x1=[-1 -1 1 1]; y1=[0 1 1 0]; x2=[0 -0.5 0 -0.5 0 0 0 -0.5 -1 -1]; y2=[1 0.5 0 0.5 1 2.25 1.5 1.25 1.25 1]; h=pi/10; t=0:h:2*pi; t1= 0.5*sin(t)+1; t2= 0.5*cos(t); t3= 0.5*sin(t)-1; t4= 0.5*cos(t); t5= 0.25*sin(t); t6=0.25*cos(t)+2.5; plot(x1,y1,'linewidth',3,'color','k') axis([-2 2 -1 4]) grid on hold on plot(x2,y2,'linewidth',4) plot(t1,t2,'color','k','linewidth',3) plot(t3,t4,'color','k','linewidth',3) plot(t5,t6,'color','k','linewidth',3)

EJERCICIO 3 hr=pi/30; t=0:hr:2*pi; x0=cos(t);y0=0*t;z0=sin(t); %rueda numero 1% x1=(x0-2);y1=(y0-1);z1=z0; %rueda delantera numero 2% x2=(0.6*x0+2);y2=(y0-1);z2=0.6*z0; %rueda numero 3% x3=(x0-2);y3=(y0+1);z3=z0; %rueda numero 4% x4=(0.6*x0+2);y4=(y0+1);z4=0.6*z0; x5=0.3*x0-1;y5=y0;z5=(0.5*z0+3); plot3(x1,y1,z1,'linewidth',3,'color','k') axis([-5 5 -4 4 -2 6]) grid on hold on plot3(x2,y2,z2,'linewidth',3,'color','k') plot3(x3,y3,z3,'linewidth',3,'color','k') plot3(x4,y4,z4,'linewidth',3,'color','k') %lineas 4 de la cuTRIMOTO%

y6=[-1 1 -0.5 -0.5 0.5 0.5 0.5 -0.5 -0.5 -0.5 -0.5 -0.5 0.5 0.5 -0.5 -0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 -0.5 -0.5 -0.5 -0.5]; x6=[-2 -2 -2 -2 -2 -2 2 2 -2 -2 0.3 0 0 0.3 0.3 -2 -2 0 0.3 0 -2 -2 -2 -2 -2 0 -2]; z6=[0 0 0 1 1 0 0 0 0 1 1 0 0 1 1 1 1 1 1 1 1.5 1 1.5 1.5 1 1 1.5]; %lineas 2 de la cuatrimoto% y7=[-1 1 -0.5 0 0.5 0 -0.5 -0.5 -0.5 0.5 0.5]; x7=[2 2 2 1 2 1 1 1 1 1 1]; z7=[0 0 0 1.5 0 1.5 1.5 1.7 1.5 1.5 1.7]; %cuerpo% x8=[0 1 0 1 -1 -1 -1 0.5 1 0.5 0 0.5 1]; y8=[0.5 0 -0.5 0 0 0 0 0.5 0.5 0.5 0 -0.5 -0.5]; z8=[0 1 0 1 1 2.5 2 1 1.7 1 2 1 1.7]; %sombrero% x9=3*[-0.23 -0.2 0.2 0.23 -0.23 -0.1 -0.1 0.1 0.1 ]-1; y9=3*[0 0 0 0 0 0 0 0 0]; z9=3*[1.05 0.9 0.9 1.05 1.05 1.05 1.15 1.15 1.05]+0.5; plot3(x6,y6,z6,'linewidth',3,'color','r') plot3(x7,y7,z7,'linewidth',3,'color','k') plot3(x8,y8,z8,'linewidth',4,'color',[0 0 1]) patch(x5,y5,z5,[1 0.5 0.5]) patch(x9,y9,z9,[0 1 1]) title('metodos numericos fiis unheval 2015 GIOVANA INGA RIXI','color','r') hold off

EJERCICIO 4 %calcular logaritmo de los 10 numeros primos a=1; b=3; c=5; d=7; e=11; f=13;g=17; l1= log(a);l2=log(b);l3=log(c); disp('EL RESULTADO ES:') disp(l1),disp(l2),disp(l3) suma=l1+l2+l3; disp('LA SUMA ES:') disp(suma)

EJERCICIO 5 x1=[-12 -5 0 -5 -12 -5 0 -1 2 -1 0 -1 2 -1 0 2 5 2 0 2 5]; x12=[-11 -4 0 -4 -11 -4 0 1 -2 1 0 1 -2 1 0 2 5 2 0 2 5]; y1=[-3 -5 0 5 3 5 0 -3 -7 -3 0 3 7 3 0 -3 -2 -3 0 3 2]; z1=[-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ]; hhh= pi/10; u= 0:hhh:pi*2; v= 0:hhh:pi; nv= length(v) ;nu= length(u); ya=sin(v); ya=ya'; za=cos(v'); zb=za; for i=2:nu za=[za zb]; end t1=5*ya*cos(u)-5; t2=4*ya*sin(u); t2z=za; surf (t1,t2,t2z) t3=2*ya*cos(u)+2; t4=2*ya*sin(u); t4z=za; hold on surf (t3,t4,t4z) plot3(x1,y1,z1,'linewidth',3,'color','k') title('METODOS NUMERICOS FIIS UNHEVAL 2014','color', 'r')

xlabel('datos para x araña 3d','color','b') ylabel('datos para y araña 3d','color','b') zlabel('datos para z araña 3d','color','b') view([130.7 7.3]) colormap(gray) axis([-12 12 -8 8 -1 8]) grid on

EJERCICIO 6 x1=[-12 -5 0 -5 -12 -5 0 -1 2 -1 0 -1 2 -1 0 2 5 2 0 2 5]; x12=[-11 -4 0 -4 -11 -4 0 1 -2 1 0 1 -2 1 0 2 5 2 0 2 5]; y1=[-3 -5 0 5 3 5 0 -3 -7 -3 0 3 7 3 0 -3 -2 -3 0 3 2]; z1=[-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ]; hhh= pi/10; u= 0:hhh:pi*2; v= 0:hhh:pi; nv= length(v) ;nu= length(u); ya=sin(v); ya=ya'; za=cos(v'); zb=za; for i=2:nu za=[za zb]; end t1=5*ya*cos(u)-5; t2=4*ya*sin(u); t2z=za;

surf (t1,t2,t2z) t3=2*ya*cos(u)+2; t4=2*ya*sin(u); t4z=za; hold on surf (t3,t4,t4z) plot3(x1,y1,z1,'linewidth',3,'color','k') title('METODOS NUMERICOS FIIS UNHEVAL 2014','color', 'r') xlabel('datos para x araña 3d','color','b') ylabel('datos para y araña 3d','color','b') zlabel('datos para z araña 3d','color','b') view([130.7 7.3]) colormap(hot) axis([-12 12 -8 8 -1 8]) grid on

EJERCICIO 7 x1=[-12 -5 0 -5 -12 -5 0 -1 2 -1 0 -1 2 -1 0 2 5 2 0 2 5]; x12=[-11 -4 0 -4 -11 -4 0 1 -2 1 0 1 -2 1 0 2 5 2 0 2 5]; y1=[-3 -5 0 5 3 5 0 -3 -7 -3 0 3 7 3 0 -3 -2 -3 0 3 2]; z1=[-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ]; hhh= pi/10; u= 0:hhh:pi*2; v= 0:hhh:pi; nv= length(v) ;nu= length(u); ya=sin(v); ya=ya'; za=cos(v'); zb=za; for i=2:nu

za=[za zb]; end t1=5*ya*cos(u)-5; t2=4*ya*sin(u); t2z=za; surf (t1,t2,t2z) t3=2*ya*cos(u)+2; t4=2*ya*sin(u); t4z=za; hold on surf (t3,t4,t4z) plot3(x1,y1,z1,'linewidth',3,'color','k') title('METODOS NUMERICOS FIIS UNHEVAL 2014','color', 'r') xlabel('datos para x araña 3d','color','b') ylabel('datos para y araña 3d','color','b') zlabel('datos para z araña 3d','color','b') view([130.7 7.3]) colormap(colorcube) axis([-12 12 -8 8 -1 8]) grid on

EJERCICIO 8 x1=[-12 -5 0 -5 -12 -5 0 -1 2 -1 0 -1 2 -1 0 2 5 2 0 2 5]; x12=[-11 -4 0 -4 -11 -4 0 1 -2 1 0 1 -2 1 0 2 5 2 0 2 5]; y1=[-3 -5 0 5 3 5 0 -3 -7 -3 0 3 7 3 0 -3 -2 -3 0 3 2]; z1=[-1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 ]; hhh= pi/10; u= 0:hhh:pi*2; v= 0:hhh:pi; nv= length(v) ;nu= length(u); ya=sin(v);

ya=ya'; za=cos(v'); zb=za; for i=2:nu za=[za zb]; end t1=5*ya*cos(u)-5; t2=4*ya*sin(u); t2z=za; surf (t1,t2,t2z) t3=2*ya*cos(u)+2; t4=2*ya*sin(u); t4z=za; hold on surf (t3,t4,t4z) plot3(x1,y1,z1,'linewidth',3,'color','k') title('METODOS NUMERICOS FIIS UNHEVAL 2014','color', 'r') xlabel('datos para x araña 3d','color','b') ylabel('datos para y araña 3d','color','b') zlabel('datos para z araña 3d','color','b') view([130.7 7.3]) colormap(flag) axis([-12 12 -8 8 -1 8]) grid on

EJERCICIO 9 ARAÑA BIDIMENCIONAL t=0:0.6:6.3;

t1=5*cos(t)-5; t2=4*sin(t); patch(t1,t2,[0.9 0.9 0.9]) grid on axis([-15 10 -10 10]) t3=2*cos(t)+2; t4=2*sin(t); hold on patch(t3,t4,[0.9 0.9 0.9]) x1=[-12 -5 0 -5 -12 -5 0 -1 2 -1 0 -1 2 -1 0 2 5 2 0 2 5]; x12=[-11 -4 0 -4 -11 -4 0 1 -2 1 0 1 -2 1 0 2 5 2 0 2 5]; y1=[-3 -5 0 5 3 5 0 -3 -7 -3 0 3 7 3 0 -3 -2 -3 0 3 2]; plot(x1,y1,'linewidth',3,'color','b') %al colocar ':ok' las patas de la araña se esconden detras del cuerpo% xlabel('DATOS X PARA EL GRAFICO','color','r') ylabel('DATOS y PARA EL GRAFICO','color','r') title('METODOS NUMERICOS FIIS UNEHVAL 2014 ARAÑA','color','y')

EJERCICIO 10 IMAGEN 3D function cine11 axis off; m=moviein(30); for n=1:30 xa=-2:0.2:2; ya=-2:0.2:2; [x,y]=meshgrid(xa,ya); z=x.^2-y.^2+y; surf(z); title('METODOS NUMERICOS 2014 FIIS UNHEVAL','color','R') view([-37.5+6*n 30]); axis([0 25 0 30 -44]); axis off; m(:,n)=getframe; end movie(m,60,10)

EJERCICIO 11 CINE EN MOVIMIENTO function cine11giovanapag148 axis off; m=moviein(100); for n=1:30 xa=-2:0.2:2; ya=-2:0.2:2; [x,y]=meshgrid(xa,ya); z=x.^2-y.^2+y; surf(z); title('METODOS NUMERICOS 2014 FIIS UNHEVAL','color','R') view([-37.5+6*n 30]); axis([0 25 0 30 -4 4]); axis off; m(:,n)=getframe; end movie(m,60,10)

EJERCICIO 12 ENGRANAJE clear clc va=input('ingrese vueltas de A:...'); da=input('ingrese dientes de A:...'); vb=input('ingrese vueltas de B:...'); db=input('ingrese dientes de B:...'); %para que me halle el valor de las vueltas de A, le pongo el valor CERO %porque no podemos calcular ningun valor cuando le pongamos cero a las vueltas %es como decir (0==??) if (va==0) va=(vb*db)/da; disp('el valor de las vueltas de A es:...') disp(va) plot(va) %para hallar el valor los dientes de A, le pongo 1 %porque no vamos a encontrar ningun engranaje de un solo diente %es como decir (1==??)

elseif (da==1) da=(vb*db)/va; disp('el valor de los dientes de A es:...') disp(da) plot(da) %para que me halle el valor de las vueltas de B, le pongo el valor CERO %porque no podemos calcular ningun valor cuando le pongamos cero a las vueltas %es como decir (0==??) elseif (vb==0) vb=(va*da)/db; disp('el valor de las vueltas de B es:...') disp(vb) plot(vb) %para hallar el valor los dientes de B, le pongo 1 %porque no vamos a encontrar ningun engranaje de un solo diente %es como decir (1==??) else (db==1) db=(va*da)/vb; disp('el valor de los dientes de B es:...') disp(db) plot(db) end

EJERCICIO 13 EXPONENCIAL clc x=1:001:5 f=exp(x) plot(x,f) title('funcion exponencial') xlabel('x') ylabel('exp(x)')

grid on x=0:pi/2; Xa=atan(4/2); Xb=pi+atan(4/2); disp('Puntos'); disp(Xa); disp(Xb); fx=Xa:0.01:Xb; Y1=2*sin(fx); Y2=4*cos(fx); hold on plot(fx,Y1) plot(fx,Y2) hold off disp('El area es:') area=quad('2*sin(x)',Xa,Xb)-quad('2*cos(x)',Xa,Xb); disp(area);

EJERCICIO 14 EN MOVMEINTO function pruebagiovana M=moviein(10)%se usa para dar movimiento a la figura%; x=[-2*pi:0.02:2*pi];

for j=1:10 y=tan(x+j*pi/8)+tan(j/2*pi); plot(x,y,'linewidth',2,'color','r'); title('METODOS NUMERICOS PAGINA 147','color','b'); xlabel('datos para x','color','r'); ylabel('datos para y','color','r'); M(:,j)=getframe; end movie(M,10,15)

EJERCICIO 15

EN MOVIMIENTO function pruebagiovana M=moviein(10)%se usa para dar movimiento a la figura%; x=[-2*pi:0.02:2*pi]; for j=1:10 y=cos(x+j*pi/8)+tan(j/2*pi); plot(x,y,'linewidth',2,'color','r'); title('METODOS NUMERICOS FIIS UNHEVAL 2014 PAGINA 147','color','b'); xlabel('datos para x','color','r'); ylabel('datos para y','color','r'); M(:,j)=getframe; end movie(M,10,15)

EJERCICIO 16 EN MOVIMIENTO function usobar M=moviein(10)%se usa para dar movimiento a la figura%; x=[-2*pi:0.2:2*pi]; for j=1:10000 y=sec(x+j*pi/8)+sin(j/2*pi)*sin(x)+56;

plot(x,y,'linewidth',2,'color','k'); title('METODOS NUMERICOS ','color','c'); xlabel('datos para x','color','r'); ylabel('datos para y','color','r'); M(:,j)=getframe; end movie(M,10,15)

EJERCICIO 17 CARGA ELÉCTRICA clc;

global f; fprintf('Fuerza electrica para una distribucion discreta de carga \n'); fprintf('teniendo en cuenta que se encuentran en el vacio \n\n\n'); n=input('ingrese nuemro de cargas puntuales:'); q0=input('ingrese cargas puntual sobre la que se desea el analisis de fuerzas(coulomb):'); p=8.854*10^(-12); k=1/(4*pi*p); f=0; fm=[]; for i=1:1:n fprintf('carga numero: %d',i); fprintf('\n'); q1=input('ingrese carga puntual(coulomb):'); r=input('ingrese la distancia(metros):'); f=f+k*q0*q1/r^2; fm=[fm,f]; end fprintf('La fuerza total aplicada por las cargas es(newtons): %f',f); plot(fm) disp(' ') disp('gracias por usar este miniaplicador----clases de metodos numericos unhevaL 2015 GIOVANA INGA RIXI)

EJERCICIO 18

CHOQUES FRONTALES UNIDIMENSIONALES % Choques frontales unidimensionales. clear; clc; disp('Programa Colisiones frontales Elásticas'); %Ingreso de datos:(se deben ingresar los datos del problema) disp('Ingreso de datos '); disp('INGRESE:'); m1=input('masa del cuerpo 1 m1(kg.): '); v01=input('velocidad inicial del cuerpo vo1(m/s): '); d=input('distancia entre los dos cuerpos d(m): '); m2=input('masa del cuerpo 2 m2(Kg.): '); v02=input('velocidad inicial del cuerpo 2 vo2(m/s): '); disp('coeficiente de restitución de los cuerpos'); e=input('entre 0 y 1 e: '); tramos=input('Cuantos tramos para el cálculo: '); cp1=m1*v01-m1*v01; cp2=m2*v02-m1%Proceso para encontrar las velocidades de salida p0=m1*v01+m2*v02; v0e=v02-v01; ek=e*v0e; ds=-m1-m2; dv1=-p0-m2*ek; dv2=m1*ek-p0; if ds==0 disp('No tiene solución'); else v1=dv1/ds; v2=dv2/ds; end %Proceso para encontrar la cantidad de movimiento lineal % y las perdidas de energía pf=m1*v1+m2*v2; eco=0.5*m1*v01^2+0.5*m2*v02^2; ec=0.5*m1*v1^2+0.5*m2*v2^2; ep=(ec-eco)*100/eco; %Variaciones 2*v02; ce1=0.5*m1*(v1^2)-0.5*m1*(v01^2); ce2=0.5*m2*(v2^2)-0.5*m2*(v02^2); xa=d*abs(v01)/(abs(v01)+abs(v02)); ta=abs(xa/v01); %Procedimiento para datos de x1 y x2 de recorrido % Antes del choque % Condiciones iniciales para el cuerpo 1 de entrada da=xa/tramos;

dt1=ta/tramos; punto1=1; t(punto1)=0; x1(punto1)=0; x2(punto1)=d; y1(punto1)=5; y2(punto1)=5; while (x1(punto1)r0 A = 1./(r(i,j).^0.5); % Ecuación de la onda: Z(i,j) = A.*(sin(2*pi.*((r(i,j)./long)-(t/T)))); else

Z(i,j) = sin(2*pi.*((r(i,j)./long)-(t/T))); end end end surf(X,Y,Z,'Facecolor','blue','Edgecolor','none'); % Mediante este comando logramos igualar los tamaños % de los ejes. axis equal; % Sombra y luz para visualizar mejor la onda. camlight right; lighting phong; % Para crear esta animación en vez de usar el comando movie, uso % getframe, que automaticamente convierte las imagenes creadas en % nuestro bucle "for" agrupandolas en una imagen en movimieto. M(count)=getframe; count=count+1; end

EJERCICIO 72 %Rutina para simular la trayectoria de una partícula browniana % Por Vicente Torres Zúñiga clear % limpiamos memoria close all clc par=1; % número de particulas, %soporta hasta 21 particulas para diferenciar el color % espacio para los valores finales de posicion de las partículas X=zeros(par,1000); Y=zeros(par,1000); Z=zeros(par,1000); for n=1:par %número de particulas en cada interación x=zeros(1,1000); %vector de posicion de la particula y=zeros(1,1000); z=zeros(1,1000); %se define una dirección en 3D aleatoria. phi=2*pi*rand(1,1000);%crea un ángulo aleatorio para la particula theta=2*pi*rand(1,1000)-pi; %se crea el otro ángulo.

% bastan con dos angulos para cubrir el espacio for i=1:999 %se define la interacción de la partícula x(i+1)=x(i)+cos(phi(i)).*sin(theta(i)); y(i+1)=y(i)+sin(phi(i)).*sin(theta(i)); z(i+1)=z(i)+cos(theta(i)); end %se guarda la trayectoria instantanea de cada partícul X(n,:)=x; Y(n,:)=y; Z(n,:)=z; end % vector para cambiar de color en cada trayectoria C=['r' 'g' 'b' 'w' 'y' 'm' 'c' 'r' 'g' 'b' 'w' 'y' 'm' 'c' 'r' 'g' 'b' 'w' 'y' 'm' 'c']; %graficación de la trayectoria de las partículas hold on for n=1:par; plot3(X(n,:),Y(n,:),Z(n,:),C(n)); % en lugar de graficar las trayectorias de cada particula, % se grafica en esa posición el lugar que ocupa la partícula end view(3); axis tight % Ajustes en la visualización de la ventana box on hold off

EJERCICIO 73 %%%% inicia código x=0:.01:7; y=plot(x,sin(x)); hCursorbar = graphics.cursorbar(y); drawnow hCursorbar.CursorLineColor = [1,.2,.3]; % default=[0,0,0]='k' hCursorbar.CursorLineStyle = ':'; % default='-' hCursorbar.CursorLineWidth = 1; % default=1 hCursorbar.Orientation = 'vertical'; % =default hCursorbar.TargetMarkerSize = 10; % default=8 hCursorbar.TargetMarkerStyle = 'o'; % default='s' (square) %%%% fin del código

EJERCICIO 74 syms x syms y ezsurf(cos(y^2)*exp(-sqrt(y^2+x^2))) o si la funcion es: syms y syms x ezsurf(cos(y^2)^(-sqrt(y^2+x^2)))

EJERCICIO 75 METODOS DE LA FALSA POSICION

clc; fprintf('METODO DE LA FALSA POSICION \n'); a=input('Ingrese el intervalo inferior: '); c=input('Ingrese el intervalo superior: '); e=input('Ingrese el error: '); Fx=input('Ingrese la funcion: ','s'); x=a; Fa=eval(Fx); x=c; Fc=eval(Fx); if Fc*Fae) b=(c*Fa-a*Fc)/(Fa-Fc); x=b; Fb=eval(Fx); fprintf('\n %8.4f %8.4f %8.4f %8.4f %8.4f %8.4f %8.4f %8.4f %8.4f \n',a,b,c,Fa,Fb,Fc,abs(c-a),abs(a-b),abs(c-b)); if Fa*Fb0); salida2=conv(x,h); [salida',salida2']

EJERCICIO 85 figure(1); for i=1:1000 T(i)=cos(i); plot(T); drawnow; pause(0.3) end

EJERCICIO 86 t=linspace(0,0.7,100); g=7; %amortiguamiento w0=100; %frecuencia angular natural fi=1.5; %fase A=5.01; %amplitud w=sqrt(w0*w0-g*g); x=A*exp(-g*t).*sin(w*t+fi); v=-g*A*exp(-g*t).*sin(w*t+fi)+w*A*exp(-g*t).*cos(w*t+fi); e=(v.^2+w0*w0*x.^2)/2; subplot(2,2,1) plot(t,x) grid on xlabel('tiempo (s)') ylabel('posición (m)') subplot(2,2,2) plot(t,e) grid on xlabel('tiempo (s)') ylabel('energía (J)') subplot(2,2,3) plot(t,v) grid on xlabel('tiempo (s)') ylabel('velocidad (m/s)') subplot(2,2,4) plot(x,v) grid on xlabel('posición (m)') ylabel('velocidad (m/s)')

EJERCICIO 87 t=linspace(0,0.7,100); x=5*exp(-7*t).*sin(100*t+1.5); A=5*exp(-7*t); hold on plot(t,x,'r') plot(t,A,'b') plot(t,-A,'b') hold off legend('desplazamiento','amplitud') title('Oscilaciones amortiguadas') xlabel('t') ylabel('x')

EJERCICIO 88 r0=0.4; b=0.05; ang=0:pi/18:9*pi/2; r=r0*exp(b*ang); polar(ang,r,'r') title('Espiral logarítmica')

EJERCICIO 89 r=linspace(0,1,30); angulo=linspace(0,2*pi,30); [r,angulo]=meshgrid(r,angulo); x=r.*cos(angulo); y=r.*sin(angulo); z=r; mesh(x,y,z) xlabel('x-axis'); ylabel('y-axis'); zlabel('z-axis')

EJERCICIO 90 MOVIMIENTO %genera los datos t=0:pi/500:2*pi; % tiempos x=cos(t); % posiciones de la pelota % Dibuja la figura inicial figure('DoubleBuffer','on') hg=plot(x(1),0,'o','MarkerSize',25,'MarkerFaceColor','r'); %pelota en la posición inicial set(hg,'EraseMode','normal'); xlim([-1.1,1.1]); % Animación for i=1:length(x) set(hg,'XData',x(i),'YData',0); drawnow;

end EJERCICIO 91 %entrada: posición del blanco (x0,y0) y velocidad inicial v0 x0=input('impacto x0: '); y0=input('impacto y0: '); v0=input('velocidad inicial: '); g=10; %calcula los ángulos de tiro a=x0*x0*g/(2*v0*v0); b=-x0; c=y0+a; dis=b*b-4*a*c; %si el problema no tiene solución if dis1 & x1 & x