function Yprim = pendel(t,Y) % Y(1)= theta, Y(2)=d(theta)/dt, Y(3)=r % % dr % -- = f(t) is specified, it is controlled by the winch speed % dt % % the ode becomes % % dY(2) f(t) r % ----- + 2 --- Y(2) + --- sin(Y(1)) = 0 % dt Y(3) Y(3) % % which becomes first order system % dY(1) % ---- = Y(2) % dt % % dY(2) f(t) g % ---- = - 2 ---- Y(2) - ---- sin(Y(1)) % dt Y(3) Y(3) % % dY(3) % ---- = f(t) % to be specified by the programmer! % dt % g = 9.82; alpha = 0.5 ; % alpha is the winch speed th = Y(1); dth = Y(2); r = Y(3); Yprim(1,1) = dth; Yprim(3,1) = ...; Yprim(2,1) = - 2*Yprim(3,1)/r*dth - g/r*sin(th);