%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Solve the equations for the Swinging Spring % in the case of resonance % % This file is for the rate of change (roc) function % for the pendulum in 3 dimensions. % % Calculate the rate of change of xvector, where % xvector = (x,xdot,y,ydot,z,zdot). % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function xdot=roc3d(t,x) global m global g global k global l global l_0 global epsilon global epssq global omega_Z global omega_R %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% r=sqrt(x(1)^2+x(3)^2+x(5)^2); fac=omega_Z^2*(r-l_0)/r; xdot(1) = x(2); xdot(2) = - fac*x(1); xdot(3) = x(4); xdot(4) = - fac*x(3); xdot(5) = x(6); xdot(6) = - fac*x(5) - g; end