disp('risolve l''eq. diff. y''=f(t,y) dove  f  e'' definita in funct.m e la')
disp('soluzione in soluz.m')
dati;
x=[t0:.05:tf];
z=soluz(x,lambda,t0,v);
plot(x,z)
pause
  axis;
  ymin=ans(3)*1.2;
  ymax=ans(4)*1.2;
  xmin=ans(1);
  xmax=ans(2);
  axis([xmin,xmax,ymin,ymax]);
axis(axis)  
pause
  %plot(x,z)
hold on
t=t0;
y=z(1);
i=0; r=0;
while t<tf
yy=y+h*funct(t,y,lambda);
i=i+1;
y1=y;
y1=y1+h/2*funct(t,y1,lambda);
y2=y1+h/2*funct(t+h/2,y1,lambda);
%test di errore
err=(y2-yy);
if abs(err) <=tol*h
   plot(t+h,yy,'o');
   t=t+h;
   y=yy;

%pause
   h=h*min(2, .5*tol*h/abs(err));
   else
   r=r+1;
   h=h*max(.5, .5*tol*h/abs(err));
   end

end
title(['E.E.  num. rifiuti=',int2str(r),'   num. passi=',int2str(i)]);
hold off

