%
%  Second example for dop0
%
%  set the initial parameters
%
  s0 = [0;0;0;0];
  tf = 1; 
  k = -30;
  tol = 5e-5;
  eta = 0.5;
  mxit = 200;
%
%  set the number of samples
%
  N =100;
%
%  determine the initial guess for theta
%
   th = pi/3*linspace(1,0,N);
%
%  run the code
%
 [th,s,nu,la0] = dopc('bobs_dopc_b',th,s0,tf,k,tol,mxit,eta);
  fprintf(1,'Final cost is  %f \n', s(1,end))
%
%  Now plot the results
%
  time = linspace(0.0,tf,N);
 %
  u = s(1,:); v = s(2,:); y = s(3,:); x = s(4,:);
  figure;
  orient tall
  subplot(3,1,1); plot(x,y); grid; xlabel('x/gt_f^2'); ylabel('y/gt_f^2');
  subplot(3,1,2); stairs(time,th*180/pi); grid;
  ylabel('\theta (deg)'); 
  subplot(3,1,3); plot(time,u(1:end-1),'-',time,v(1:end-1),'--'); legend('u','v',2);grid;
  xlabel('t/f_f (sec)');
%
      