Change target as the model runs: target =
tmax=20; InitGraph(); ScaleWindow(-2.5,-2.5,2.5,2.5); DrawAxes(); Label('Error Phase Plane',-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; v = v + u * dt; x = x + v * dt; t = t + dt; Spot(x-xtarget, v); if (t