Change target as the model runs: target =
tmax=20; umax=4; //drive limit InitGraph(); ScaleWindow(-2.5,-2.5,2.5,2.5); DrawAxes(); Label('Phase Plane - drive limit +/-'+umax,-2,2); Label('Position error',2,-.2); Label('Velocity',.1,2); f=8; //Feedback coefficient d=2; //damping coefficient t=0; LineStart(x-xtarget,v); StepModel();
//function StepModel() Colour(Black); u = f*(xtarget - x) -d * v; if (u>umax) {u=umax; Colour(Red);} if (u<-umax){u=-umax; Colour(Red);} v = v + u * dt; x = x + v * dt; t = t + dt; Spot(x-xtarget, v); if (t