Change target as the model runs: target =
tmax=20; InitGraph(); ScaleWindow(0,-2.5,tmax,2.5); DrawAxes(); Label('Second order example - closed loop',1,35); f=8; //Feedback coefficient d=2; //damping coefficient Colour(Black); t=0; LineStart(t,x); StepModel();
//function StepModel() u = f*(xtarget - x) -d * v; v = v + u * dt; x = x + v * dt; t = t + dt; LineTo(t, x); if (t