Change demand as the model runs: demand =
tmax=10; dt=.05; InitGraph(); ScaleWindow(0,-10,tmax,30); DrawAxes(); Label('Position control - no limit',1,25); A[0]=Array( 0, 1); //A-matrix of the system A[1]=Array( 0, 0); B=Array( 0, 1); x=Array( 10, 0); //Initial position and velocity Colour(Black); t=0; LineStart(t,x[0]); StepModel();
//executed in StepModel() u=-6*x[0]-5*x[1]+6*demand; 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