The position v of a mass in a massspringdashpot system see F
Solution
Function Y position:
function y = Yposition(t)
 m=25; %kg
 c=10; %N-s/m
 k=200; %N/m
 Fo=100; %N
 w=2*k/m;%rad/s
 A=0.2; %m
 B=(c/2/m)*(A/(sqrt((k/m)-(c/2/m)^2)));
 yc=exp(-c.*t/2/m).*(A*cos((sqrt((k/m)-(c/2/m)^2)).*t)+B*sin((k/m)-(c/2/m)^2).*t);
  yp=((Fo/m)/((c*w/m)^2+((k/m)-w^2))).*(((k/m)-w^2)*sin(w.*t)-(c*w/m)*cos(w.*t));
  y=yc+yp;
Answers:
%Matlab Code Help
 clc
 clear all
 t=[0:0.000001:10]; %time
 y=Yposition(t);
%Answer 1: The plot
 figure
 plot(t,y)
 legend(\'y=position\')
 xlabel(\'Time [s]\')
 ylabel(\'Y Position [m]\')
 grid on
%Answer 2:The # roots, the roots values and the value of y(roots)
 c=0;
 for i=1:length(t)-1;
 if sign(y(i)) ~= sign(y(i+1))%when the sign change the function cross the x axis
 c=c+1; %Numbers of roots
 tr(c)=(t(i)-t(i+1))/(y(i)-y(i+1))*(-y(i)) + t(i);% tr = Roots Values
 yr(c)=Yposition(tr(c));%yr=y(root)
 end
 end
Regards

