

tmax=20;nb_pts=50;

deff('[xdot]=f(t,x)','xdot=dyn(t,x)-har(t,x);..
                      if x <0 then xdot=0; end');

t0=0;t=t0:(tmax/nb_pts):tmax;

xmax=K;

vx=0:(xmax/nb_pts):xmax;
vy=feval(t0,vx,dyn);
vu=feval(t0,vx+1e-3,har);
ymax=max(max(vy),max(vu));

xset('window',0);
xbasc();
xselect();

subplot(1,2,2);
plot2d([0],[0],strf='011',rect=[0,0,tmax,xmax]);
xtitle("","temps","x");
if isdef('x_e') then xset('line style',2);
                     plot2d([0,tmax],[x_e,x_e]);
                     xset('line style',1);
end;

subplot(1,2,1);
plot2d(vx,[vy' vu'],[5,3],strf='011',rect=[0,0,xmax,ymax]);
xtitle("Vitesses","x","");

rep=xclick();

while rep(1)==0
x=ode(rep(2),t0,t,f);
subplot(1,2,2);
if size(t)==size(x) then plot2d(t,x,2,strf='011',rect=[0,0,tmax,xmax]);
end;
subplot(1,2,1);
rep=xclick();
end;
