a.)Use   the   data   obtained   from   (a)   to   determine   the   time   at   which   the   spring   will

remain   within   (+/-)   0.1%   of   its   equilibrium   position   (x=0).  

This is my code and graph as of now. I dont now how to find that value for part a

%clear all variables
clear all
%constants
cm = 10;
km = 2;
%intial conditions
x1(1)=-2;
x2(1)=0;
%stepsize
tmax=10;
tmin=0;
N=500;
h=(tmax-tmin)/N;

T2(1)=0;
% for loop to solve m
for i =1:N
T(i+1)=i*h;
x1(i+1) = x1(i)+ x2(i)*h;
x2(i+1) = x2(i)+(-cm*(x1(i)))-km*(x2(i))*h;
end
C_analytical = exp(-T).*(-2*cos(3*T))-(2/3)*(sin(3*T));

plot(T,x1,’m’)
xlabel(‘Time’);
ylabel(‘Position’)
%hold on
%plot(T,C_analytical)



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *