ejercicios resueltos Matlab

135
2015 SOLUCIONARIO DE 100 EJERCICIOS Tiburcio Gobea, Álvaro MÉTODOS NUMÉRICOS. Ing. CHAVEZ ESTA!A, "orge. UNIVERSIDAD NACIONAL “HERMILIO VALDIZÁN MEDRANO” HUÁNUCO E.A.P. Ingenier! In"#$%ri!& '!(#&%!" "e Ingenier! In"#$%ri!& ) Si$%e*!

description

ejercicios resueltos Matlab

Transcript of ejercicios resueltos Matlab

EJERCICIOS EN MATLAB METODOS NUMERICOS 10/07/15

2015 SOLUCIONARIO DE 100 EJERCICIOS

1. Tiburcio Gobea, lvaroMTODOS NUMRICOS.Ing. CHAVEZ ESTRADA, Jorge.

UNIVERSIDAD NACIONAL HERMILIO VALDIZN MEDRANOHUNUCOE.A.P. Ingeniera IndustrialFacultad de Ingeniera Industrial y Sistemas

EJERCICIO 1x01=[-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 onhold onplot (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%ciclistax1=[-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 onhold onplot(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 3hr=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 onhold onplot3(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 primosa=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 5x1=[-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];endt1=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 onsurf (t3,t4,t4z)plot3(x1,y1,z1,'linewidth',3,'color','k')title('METODOS NUMERICOS FIIS UNHEVAL 2014','color', 'r')xlabel('datos para x araa 3d','color','b')ylabel('datos para y araa 3d','color','b')zlabel('datos para z araa 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];endt1=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 onsurf (t3,t4,t4z)plot3(x1,y1,z1,'linewidth',3,'color','k')title('METODOS NUMERICOS FIIS UNHEVAL 2014','color', 'r')xlabel('datos para x araa 3d','color','b')ylabel('datos para y araa 3d','color','b')zlabel('datos para z araa 3d','color','b')view([130.7 7.3])colormap(hot) axis([-12 12 -8 8 -1 8])grid on

EJERCICIO 7x1=[-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];endt1=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 onsurf (t3,t4,t4z)plot3(x1,y1,z1,'linewidth',3,'color','k')title('METODOS NUMERICOS FIIS UNHEVAL 2014','color', 'r')xlabel('datos para x araa 3d','color','b')ylabel('datos para y araa 3d','color','b')zlabel('datos para z araa 3d','color','b')view([130.7 7.3])colormap(colorcube) axis([-12 12 -8 8 -1 8])grid on

EJERCICIO 8x1=[-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];endt1=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 onsurf (t3,t4,t4z)plot3(x1,y1,z1,'linewidth',3,'color','k')title('METODOS NUMERICOS FIIS UNHEVAL 2014','color', 'r')xlabel('datos para x araa 3d','color','b')ylabel('datos para y araa 3d','color','b')zlabel('datos para z araa 3d','color','b')view([130.7 7.3])colormap(flag) axis([-12 12 -8 8 -1 8])grid on

EJERCICIO 9ARAA BIDIMENCIONALt=0:0.6:6.3;t1=5*cos(t)-5;t2=4*sin(t);patch(t1,t2,[0.9 0.9 0.9])grid onaxis([-15 10 -10 10])t3=2*cos(t)+2;t4=2*sin(t);hold onpatch(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 araa 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 ARAA','color','y')

EJERCICIO 10IMAGEN 3Dfunction cine11axis 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;endmovie(m,60,10)

EJERCICIO 11CINE EN MOVIMIENTOfunction cine11giovanapag148axis 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;endmovie(m,60,10)

EJERCICIO 12ENGRANAJEclearclcva=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 13EXPONENCIALclcx=1:001:5f=exp(x)plot(x,f)title('funcion exponencial')xlabel('x')ylabel('exp(x)')grid onx=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 onplot(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 14EN MOVMEINTOfunction pruebagiovanaM=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;endmovie(M,10,15)

EJERCICIO 15

EN MOVIMIENTOfunction pruebagiovanaM=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;endmovie(M,10,15)

EJERCICIO 16EN MOVIMIENTOfunction usobarM=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;endmovie(M,10,15)

EJERCICIO 17

CARGA ELCTRICAclc;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 18CHOQUES FRONTALES UNIDIMENSIONALES% Choques frontales unidimensionales.clear;clc;disp('Programa Colisiones frontales Elsticas');%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 restitucin de los cuerpos');e=input('entre 0 y 1 e: ');tramos=input('Cuantos tramos para el clculo: '); cp1=m1*v01-m1*v01;cp2=m2*v02-m1%Proceso para encontrar las velocidades de salidap0=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 solucin');else v1=dv1/ds; v2=dv2/ds;end%Proceso para encontrar la cantidad de movimiento lineal% y las perdidas de energapf=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 entradada=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)r0A = 1./(r(i,j).^0.5);% Ecuacin de la onda:Z(i,j) = A.*(sin(2*pi.*((r(i,j)./long)-(t/T))));elseZ(i,j) = sin(2*pi.*((r(i,j)./long)-(t/T))); endendend surf(X,Y,Z,'Facecolor','blue','Edgecolor','none'); % Mediante este comando logramos igualar los tamaos% de los ejes.axis equal; % Sombra y luz para visualizar mejor la onda.camlight right;lighting phong; % Para crear esta animacin 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 partcula browniana% Por Vicente Torres Zigaclear % limpiamos memoriaclose allclcpar=1; % nmero de particulas,%soporta hasta 21 particulas para diferenciar el color% espacio para los valores finales de posicion de las partculasX=zeros(par,1000);Y=zeros(par,1000);Z=zeros(par,1000);for n=1:par %nmero de particulas en cada interacinx=zeros(1,1000); %vector de posicion de la particulay=zeros(1,1000);z=zeros(1,1000);%se define una direccin en 3D aleatoria.phi=2*pi*rand(1,1000);%crea un ngulo aleatorio para la particulatheta=2*pi*rand(1,1000)-pi; %se crea el otro ngulo.% bastan con dos angulos para cubrir el espaciofor i=1:999 %se define la interaccin de la partculax(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 partculX(n,:)=x;Y(n,:)=y;Z(n,:)=z;end% vector para cambiar de color en cada trayectoriaC=['r' 'g' 'b' 'w' 'y' 'm' 'c' 'r' 'g' 'b' 'w' 'y' 'm' 'c' 'r' 'g' 'b' 'w' 'y' 'm' 'c'];%graficacin de la trayectoria de las partculashold onfor 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 posicin el lugar que ocupa la partculaendview(3);axis tight % Ajustes en la visualizacin de la ventanabox onhold off

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

EJERCICIO 74syms xsyms yezsurf(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 75METODOS DE LA FALSA POSICIONclc;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 84SEAL CONTINUAclcclearpause onx=[0 1 2 3 4 3 2 1 0]; %Respuesta al impulso unitario h=[1 1 1 1 1 1 1 1 ]; %Seal de entradam=length(x);n=length(h);%invierte el vector hhi=fliplr(h);k=20;X=[x,zeros(1,40-m)];X= X([ end-k+1:end 1:end-k ]);H=[h,zeros(1,40-n)];H= H([ end-k+1:end 1:end-k ]);xn=-20:20-1;Y=zeros(1,40);p=zeros(1,40);h1=subplot(3,1,1);plot(xn,X,'-g')ylabel('h(t)')title('Respuesta al impulso unitario')% colocar(h1,'YLim',[a b])h2=subplot(3,1,2);plot(xn,H,'-y')% colocar(h2,'YLim',[a b])pause(3)h2=subplot(3,1,3);plot(xn,Y,'-m')%cicloHi=[hi,zeros(1,40-n)];for i=1:40-np=X.*Hi;Y(i+n-1)=sum(p);subplot(3,1,2);plot(xn,Hi,'-r')ylabel('x(t)')title('Seal de entrada')subplot(3,1,3)plot(xn,Y,'-m')xlabel('Tiempo [s]')ylabel('y(t)')title('Seal de salida')Hi= Hi([ end 1:end-1 ]);pause(0.5)endpause offsalida=Y(abs(Y)>0);salida2=conv(x,h);[salida',salida2']

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

EJERCICIO 86t=linspace(0,0.7,100);g=7; %amortiguamientow0=100; %frecuencia angular naturalfi=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 onxlabel('tiempo (s)')ylabel('posicin (m)')subplot(2,2,2)plot(t,e)grid onxlabel('tiempo (s)')ylabel('energa (J)')subplot(2,2,3)plot(t,v)grid onxlabel('tiempo (s)')ylabel('velocidad (m/s)')subplot(2,2,4)plot(x,v)grid onxlabel('posicin (m)')ylabel('velocidad (m/s)')

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

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

EJERCICIO 89r=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 90MOVIMIENTO%genera los datost=0:pi/500:2*pi; % tiemposx=cos(t); % posiciones de la pelota% Dibuja la figura inicialfigure('DoubleBuffer','on')hg=plot(x(1),0,'o','MarkerSize',25,'MarkerFaceColor','r'); %pelota en la posicin inicialset(hg,'EraseMode','normal'); xlim([-1.1,1.1]); % Animacinfor i=1:length(x) set(hg,'XData',x(i),'YData',0); drawnow;end

EJERCICIO 91%entrada: posicin del blanco (x0,y0) y velocidad inicial v0x0=input('impacto x0: ');y0=input('impacto y0: ');v0=input('velocidad inicial: ');g=10; %calcula los ngulos de tiroa=x0*x0*g/(2*v0*v0); b=-x0; c=y0+a;dis=b*b-4*a*c; %si el problema no tiene solucinif dis1 & x1 & x