Skip to content
Permalink
6b4454f569
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
18 lines (17 sloc) 484 Bytes
function dr=ode3(t,r,l,k,m)
% first order ODE for pendulum attached to 2 springs
% l is pendulum length
% k is spring stiffness of one spring
% m is mass of pendulum bob
g=9.81;
dr=zeros(size(r));
dr(1)=r(2); % dtheta/dt=dtheta/dt
dr(3)=r(4); % dy/dt=dy/dt
if abs(r(1))<=0.2
dr(2)=-2*k*g/(2*k*l+m*g)*r(1);
dr(4)=-2*k/m*r(3);
else
ddy=1/l*1/sin(r(1))^2*[1 -cos(r(1));-l*cos(r(1)) l]*[-g*sin(r(1));-2*k/m*r(3)];
dr(2)=ddy(1);
dr(4)=ddy(2);
end