Change target as the model runs: target =
tmax=20; InitGraph(); ScaleWindow(0,-20,tmax,20); DrawAxes(); Label('Predictive control - fourth order - all offside',1,18); Colour(Black); t=0; x=10;v=0;a=0; Spot(t,x); StepModel();
//function StepModel() var uf = 1; af=a; jf=j; vf=v; xf=x; tf=t; toff=0; Colour(Green); while((jf<0)||(af<0)||(vf<0)||(xf
0)||(af>0)||(vf>0)||(xf>xtarget)){ jf = jf + uf * dtf; af = af + jf * dtf; vf = vf + af * dtf; xf = xf + vf * dtf; tf = tf + dtf; Spot(tf, xf); } if(tf>tpos){u=-1;}else{u=1;} Colour(Black); LineStart(t, x); j = j + u * dt; a = a + j * dt; v = v + a * dt; x = x + v * dt; t = t + dt; LineTo(t, x); Colour(Blue); Spot(t, 10*j); if (t