Write a MATLAB program to analyze free vibration of viscousl
Solution
The following MATLAB code can be executed.
%Free Vibration response of a linear single degree of freedom system
m = input(\'mass of the system in kg\');
k=input( \'Stiffness of the system in N/m =\' );
c=input( \'damping factor of the system in N.S/m= \' );
x0=input(\'initial Displacement in m= \');
xt0=input(\'initial velocity in m/s= \');
wn=sqrt(k/m);
zeta=c/(2*m*wn);
if (zeta >1);
t=0:0.001:20;
%overdamped
z1=-zeta+sqrt(zeta^2-1);
z2=-zeta-sqrt(zeta^2-1);
z3=2*wn*sqrt(zeta^2-1);
A=(xt0-z2*wn*x0)/z3;
B=(-xt0+z1*wn*x0)/z3;
x1=A*exp(z1*wn*t)+B*exp(z2*wn*t);
if (zeta==1);
t=0:0.001:20;
%critically damped
x2=(x0+(xt0+wn*x0)*t).*exp(-wn*t)
if (zeta<1);
t=0:0.001:20;
%underdamped
zt=zeta; %Damping factor
wd=wn*sqrt(1-zt^2);
x3=exp(-zt*wn*t).*(((xt0+zt*wn*x0)/wd).*sin(wd*t)+x0*cos(wd*t));
plot(t,x1,\'r\',t,x2,\'b\',t,x3,\'g\',\'linewidth\',2)
grid on
set(gca,\'FontSize\',15) % For changing fontsize of tick no
xlabel(\'\\bf Time\',\'Fontsize\',15)
ylabel(\'\\bf x\',\'Fontsize\',15)

