%
%  code10Fd.m -- 08 nov 02 -- djm
%
%  - runge-kutta method example

clear

%  set initial value as row vector

IV = [1 0];

%  invoke runge-kutta solver

opt = odeset('RelTol',1e-3,'AbsTol',1e-6);
[t y] = ode45(@Fode,[0 4*pi],IV,opt);

%  plot results & exact in green 
%  - t is column vect of times
%  - y is matrix whose rows are solutions & rows are at diff times

figure(1);  clf;  hold on
plot(t, cos(t),'g')
plot(t,-sin(t),'g')

%  plot all times of 1st & 2nd components of y(t)

plot(t,y(:,1),'b')
plot(t,y(:,2),'r')

title('\bf runge-kutta solution')
xlabel('\bf t-axis')
ylabel('\bf u(t) in blue & v(t) in red')

error = y(end,1)-1
