tmax = 50; demand = 0; dt = .01; InitGraph(); ScaleWindow(-2,-3,5,1); DrawAxes(); Label('Phase plane - limit at 1.0',1,.5); x = 5; v = 0; //Initial position and velocity Colour(Black); t = 0; LineStart(x-demand,v); StepModel();
//executed in StepModel() u = -6*(x-demand) -5*v; Colour(Black); if (u>1){u = 1;Colour(Red);} if (u<-1){u = -1;Colour(Red);} v = v + u*dt; x = x + v*dt; t = t + dt; Spot(x, v); if(Math.abs(x)+Math.abs(v)<0.1){x=5*Math.random();} if (t