Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

clear all

clc;
close all;
m=input("Enter the Lumped mass: ");
5 k(1)=input("Enter the Monoshock suspension stiffness: ");
k(2)=input("Enter the Gas Filled suspension stiffness: ");
xo=input("Enter the initial displacement: ");
vo=input("Enter the initial velocity: ");
tf=input("Enter the testing time duration, in seconds: ");
10 for zi=1:2
zeta(zi)=12;
while (zeta(zi)<0 | zeta(zi)>=1)
zeta(zi)=input("Enter damping coefficient value: ");
if (zeta(zi)>=1 | zeta(zi)<0)
15 fprintf("Zeta must be between 0 and 1.");
zeta(zi)=12;
end
end
end
20
for i=1:2
wn(i)=(1/(2*pi))*(sqrt(k(i)/m));
wd(i)=wn(i)*sqrt(1-zeta(i)^2);
end
25 t=0:tf/1000:tf;
for j=1:2
a=sqrt((wn(j)*xo*zeta(j)+vo)^2+(xo*wd(j))^2)/wd(j);
phi=atan2(wd(j)*xo,vo+zeta(j)*wn(j)*xo);
x(j,:)=a*exp(-zeta(j)*wn(j)*t).*sin(wd(j)*t+phi);
30 end

subplot(2,1,1)
plot(t,x(1,:))
title(['Response for zeta=',num2str(zeta(1))])
35 ylabel('Response x')
grid
subplot(2,1,2)
plot(t,x(2,:))
title(['Response for zeta=',num2str(zeta(2))])
40 ylabel('Response x')
grid

You might also like