% FILE: dyn310.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) % % 2-DOF COUPLED UNDAMPED FORCED RESPONSE % % WHO: LLW % WHEN: 1 DEC 1996 % function heading function ydot = dyn310(t, y) %---define k and m--- k1 = 8; k2 = 0; k3 = 0; m1 = 2; m2 = 2; c1 = 1; c2 = 0; c3 = 0; %---define the A matrix--- M = [ m1 , 0 ; 0 , m2 ]; MINV = inv(M); 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; -MINV*K -MINV*C ]; %---define the forcing function fbar = [ 0; 0; (MINV * [1;0])]; omega = 2; %---define the forcing function---- B = fbar * cos( omega * t); if t == (-9999) % for debugging and testing ydot = A; else %---compute ydot--- ydot = A * y + B; end