%Ejercicio 3 %Beltrán Gutiérrez m=20; %masa del cuerpo k=20; %constanteelástica del muelle %condiciones iniciales x0=[1,0]; % 1 es posición inicial, 0 es velocidad inicial tf=40; %tiempo final figure(3) for c=[5,40,200] f=@(t,x) [x(2);(-k*x(1)-c*x(2))/(m)]; % x(1) es el desplazamiento y x(2) es la velocidad [t,x]=ode45(f,[0,tf],x0); plot(t,x(:,1)) hold on end legend('Cte de amortiguación 5','Cte de amortiguación 40','Cte de amortiguación 200') grid on xlabel('Tiempo (s)') ylabel('Desplazamiento (m)'); title('Sistema masa-resorte-amortiguador')
