% % Mass-Spring-Damper system % ODE45 solver solution % ODE45 subprogram % function ydot = forcedsub(t,y) m = 2; % mass of the system in meter k = 5000; % stiffness of the spring (N/m) c = 30; % damping coefficient P = 100; % magnitude of force Omega = 20; % frequency of force yd1 = y(2); yd2 = (-k*y(1)-c*y(2)+P*sin(Omega*t))/m; ydot = [yd1;yd2];