%%%   A menu for setting up different initial value problem
%%%       solvers
clc
compare=0;
setup=1;
while setup==1;
   help odesetup
	p = input('Select the number of item to be set up: ');
   if ((p <= 0) | (p > 11)) 
		break
   end
   if p==1;
     Fun=input('input name of function m-file:  ','s');
   elseif p==2;
     t0=input('input initial value of t, t0:  ');
   elseif p==3;
     tlast=input('input last value of t, tlast:  ');
   elseif p==4;
     w0=input('input initial value of solution w0;  ');
   elseif p==5;
     N=input('input number of steps N:  ');
   elseif p==6;
     hmax=input('input max step size, hmax:  ');
   elseif p==7;
     hmin=input('input min step size, hmin:  ');
   elseif p==8;
     TOL=input('input local error tolerence, TOL:  ');
   elseif p==9;
     data  =input('input vector  [t0,tlast,w0,N]:  ');
      t0=data(1);tlast=data(2);w0=data(3);N=data(4);
   elseif p==10;
     data =input('input [t0,tlast,w0,hmax,hmin,TOL]:  ');
     t0=data(1);tlast=data(2);w0=data(3);hmax=data(4);hmin=data(5);TOL=data(6);
   elseif p==11;
      setup=0;
   end;
   while (setup==0 )
      clc
      help odeprog
	n = input('Select the number of solver: ');
	if ((n <= 0) | (n > 16)) 
		break
	end
        if (n==1)
             [tout,yout] = heun_2(Fun,t0,tlast,w0,N);
        elseif (n==2)
             [tout,yout] = modeul_2(Fun,t0,tlast,w0,N);
        elseif (n==3)
             [tout,yout] = rkmid_2(Fun,t0,tlast,w0,N);
        elseif (n==4)
             [tout,yout] = rk4(Fun,t0,tlast,w0,N);
        elseif (n==5)
             [tout,yout] = ab_2step(Fun,t0,tlast,w0,N);
        elseif (n==6)
             [tout,yout] = ab_3step(Fun,t0,tlast,w0,N);
        elseif (n==7)
             [tout,yout] = ab_4step(Fun,t0,tlast,w0,N);
        elseif (n==8)
             [tout,yout] = ab_5step(Fun,t0,tlast,w0,N);
        elseif (n==9)
             [tout,yout] = precor54(Fun,t0,tlast,w0,N);
        elseif (n==10)
             [tout,yout] = milnesim(Fun,t0,tlast,w0,N);
        elseif (n==11)
             [tout,yout] = rksys57(Fun,t0,tlast,w0,N);
        elseif (n==12)
             [tout,yout] = pcsys54(Fun,t0,tlast,w0,N);
        elseif (n==13)
             [tout,yout] = rkf53_2(Fun,t0,tlast,w0,hmax,hmin,TOL);
        elseif (n==14)
             [tout,yout] = precor55(Fun,t0,tlast,w0,hmax,hmin,TOL);
        elseif (n==15)
             [tout,yout] = extra56(Fun,t0,tlast,w0,hmax,hmin,TOL);
        elseif (n==16)
             [tout,yout] = rkfsys(Fun,t0,tlast,w0,N);
        end;
    plot(tout,yout);pause
        if (compare==1)
            [rows,col]=size(Tout);ltout=length(tout);lyout=length(yout);
            if (rows > ltout)
                 tout(ltout:rows)=tout(ltout)*ones(ltout:rows);
                 yout(lyout:rows)=yout(lyout)*ones(lyout:rows);
            elseif (rows < ltout);
                 Tout(rows:ltout,:)=ones(rows:ltout,col)*Tout(rows,:)';
                 Yout(rows:lyout,:)=ones(rows:lyout,col)*Yout(rows,:)';
             end;
             Tout=[Tout,tout];Yout=[Yout,yout];
             plot(Tout,Yout);pause
        end;
    help choice
	q = input('Select number: ');
	if ((q <= 0) | (q > 4)) 
		break
        elseif (q==1)
              setup=0;compare=0;
	elseif (q==2&compare==0)
              setup=0; compare=1;Tout=tout;Yout=yout;
	elseif (q==2&compare==1)
              setup=0; 
	elseif (q==3)
              setup=1;compare=0; 
	elseif (q==4&compare==0)
              setup=1;compare=1;Tout=tout;Yout=yout; 
	elseif (q==4&compare==1)
              setup=1;compare=0; 
        end;
    end;
end;
