% FILE: dyn200.m % WHAT: function for use with ODE45 for simulating 2-DOF undamped % unforced spring-mass system % This function accepts: t (scalar) and y (4x1) as arguments % This function returns: ydot = A * y (ydot is 4x1) % % SUMULATES AN UNDAMPED 2-DOF SYSTEM % % WHO: LLW % WHEN: 1 DEC 1996 % function heading function ydot = dyn200(t, y) %---define k and m--- k1 = 8; k2 = 8; k3 = 8; m1 = 2; m2 = 2; c1 = 0; c2 = 0; c3 = 0; %---define the A matrix--- M = [ m1 , 0 ; 0 , m2 ]; K = [ k1+k2 , (-k2) ; (-k2) , k2+k3 ]; C = [ c1+c2 , (-c2) ; (-c2) , c2+c3 ]; IDENT = [ 1 0 ; 0 1 ]; ZERO = [ 0 0 ; 0 0 ]; A = [ ZERO IDENT; -inv(M)*K -inv(M)*C ]; % ---compute ydot--- ydot = A * y; % Return the A matrix only for debugging and testing if t == (-9999) ydot = A; end