Page 377 - MATLAB an introduction with applications
P. 377
362 ——— MATLAB: An Introduction with Applications
Example E6.11: Find the response of the two degree of freedom system when F (t) = 0 and F (t) = 10, using
2
1
the central difference method. The mass, stiffness and damping matrices for this system are given as
1 0 11 –1 0.5 –0.1
[ ] = , K , C
[ ] =
[ ] =
M
0 10 –1 1 –0.1 0.1
All the initial conditions are given as zero. Use ∆t = 0.05
Solution: The procedure is modified for matrices instead of scalars. Complete program is given below:
% INITIAL VALUES
M=[1 0;0 10];
K=[21 –1;–1 1];
C=[0.5 –0.1;–0.1 0.1];
dt=0.05;
x0=[0;0];x0d=[0;0];
F0=[0;10];
T=2;
x0dd=inv(M)*(F0–C*x0d–K*x0);
xprev=x0–(dt.*x0d)+((dt^2).*(x0dd/2));
a0=1/dt^2;a1=1/(2*dt);a2=2*a0;
mbar=(a0.*M)+(a1.*C);
t=0;
v(:,1)=x0d;a(:,1)=x0dd;
i=1;
fprintf(‘time\t\tX(1)\t\tX(2)\n’);
for t=0:dt:T+dt
X(:,i)=x0;
F=F0;
Fbar=F+(a2.*M–K)*x0+(a1.*C–a0.*M)*xprev;
x=inv(mbar)*Fbar;
xprev=x0;
x0=x;
fprintf(‘%f\t%f\t%f\n’,t,X(1,i),X(2,i));
i=i+1;
p=i;
end
for i=2:p–1
if i<p–1

