Change demand as the model runs: demand =
tmax = 10; dt = .01; 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=6; d=5; k=10; LineStart(t,x); StepModel();
//executed in StepModel() vest = k * (x - xslow) xslow = xslow + vest * dt u = -f*(x-demand) -d*vest; v = v + u*dt; x = x + v*dt; t = t + dt; LineTo(t, x); if (t