% % code10Fe.m -- 08 nov 02 -- djm % % - runge-kutta method for coupled pendula clear % set initial value as column vector IV = [1 0 0 0]; % invoke runge-kutta solver opt = odeset('RelTol',1e-3,'AbsTol',1e-6); [t y] = ode45(@Fpendula,[0 40*pi],IV,opt); % plot results for theta(t) and phi(t) figure(1); clf; hold on plot(t,y(:,1),'b') plot(t,y(:,3),'r') title('\bf runge-kutta solution') xlabel('\bf t-axis') ylabel('\bf \theta(t) in blue & \phi(t) in red')