Change demand as the model runs: demand =
tmax = 10; dt = .5; InitGraph(); ScaleWindow(0,-10,tmax,30); DrawAxes(); Label('Position control - estimated velocity',1,25); x = 20; xslow=20; v = 0; //Initial position and velocity Colour(Black); t = 0; f=2; d=1; k=1; LineStart(t,x); StepModel();
//executed in StepModel() vest = k * (x - xslow) xslow = xslow + vest * dt u = -f*(x-demand) -d*vest; x = x + v*dt+u*dt*dt*2; v = v + u*dt; t = t + dt; LineTo(t, x); if (t