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

% give mass of the system

m=6;
%give stiffness of the system
k=8;
wn=sqrt(k/m);
%give damping coefficient
c1=2;
%give initial conditions - displacement and velocity
u(1)=.25;
udot(1)=.5;
% give magnitude of harmonic force
f=4;
%give excited frequency of the force
w=1;
%****************************************************
beta=w/wn;
cc=2*sqrt(k*m);
rho=c1/cc;
wd=wn*sqrt(1-rho^2);
wba=rho*wn;
rhoba=rho/sqrt(1-rho^2);
b0=2.0*rho*wn;
b1=wd^2-wn^2;
b2=2.0*wba*wd;
dt=0.02;
t(1)=0;
for i=2:1500
t(i)=(i-1)*dt;
s=exp(-rho*wn*t(i))*sin(wd*t(i));
c=exp(-rho*wn*t(i))*cos(wd*t(i));
sdot=-wba*s+wd*c;
cdot=-wba*c-wd*s;
sddot=-b1*s-b2*c;
cddot=-b1*c+b2*s;
a1=c+rhoba*s;
a2=s/wd;
d=-2.0*f*(rho*beta)/(k*(1-beta^2)^2+(2*rho*beta)^2);
e=f*(1-beta^2)/(k*(1-beta^2)^2+(2*rho*beta)^2);
u(i)=a1*u(1)+a2*udot(1)-d*(c+wba*s/wd)-e*w*s/wd;
v(i)=d*(cos(w*t(i)))+e*sin(w*t(i));
x(i)=u(i)+v(i);
end
figure(1);
plot(t,x,‘k’);
xlabel(‘ time’);
ylabel(‘ displacement ’);
title(‘ displacement - time’);

You might also like