You are on page 1of 2

clc;

close all;
m=2;
k=8;
dt=0.02;
w=sqrt(k/m);
y=dsolve(‘D2y=-2^2*y’,‘y(0)=3’,‘Dy(0)=5’,‘x’);
simplify(y)
for i=1:1500
t(i)=(i-1)*dt;
z(i)=3*cos(w*t(i))+5*sin(w*t(i))/w;
v(i)=-w*3*sin(w*t(i))+5*cos(w*t(i));
a(i)=-3*w^2*cos(w*t(i))-5*w*sin(w*t(i));
end
figure(1)
plot(t,z,‘k’)
xlabel(‘t’)
ylabel(‘u’)
title(‘ Displacement Time Curve’)
figure(2)
plot(t,v,‘k’)
xlabel(‘t’)
ylabel(‘v’)
title(‘Velocity time curve’)
figure(3)
plot(t,a,‘k’)
xlabel(‘t’)
ylabel(‘a’)
title(‘Acceleration time curve’)

You might also like