Contents

% Raquel Fernandez Gomez

EJERCICIO 3 %%%

% Resolución de una ODE de segundo orden
% Método de "ode45"

m=20; % masa del cuerpo
k=20; % cte elá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,20]
    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 20')
grid on
xlabel('Tiempo (s)')
ylabel('Desplazamiento (m)');
title('Sistema masa-resorte-amortiguador')