Change command as the model runs: Command =
tmax=10; dt=.05; InitGraph(); ScaleWindow(0,-10,tmax,30); DrawAxes(); Label('Second order position control',1,25); A[0]=Array( 0, 1); //A-matrix of the system A[1]=Array(-6,-2); B=Array( 0, 6); x=Array( 0, 0); //Initial position and velocity Colour(Black); t=0; LineStart(t,x[0]); StepModel();
//executed in StepModel() u=command; for(var i=0;i<=1;i++){ for(var j=0;j<=1;j++){ x[i]+=A[i][j]*x[j]*dt; } x[i]+=B[i]*u*dt; } t = t + dt; LineTo(t, x[0]); if (t