clc clg echo off; % Demo942.m program to generate the dynamic matrix coefficients from % a state space model of a process % Copyright 1992 by Babu Joseph % Washington University, St.Louis, Mo % The following quantities must be defined before calling this program % ad,bd,cd,dd discrete state space model % p the horizon time for step response % n the control move horizon pause % press any key clc; % perturb input 1 [y,x]=dstep(ad,bd,cd,dd,1,p+1); a11=y(2:p+1,1);a21=y(2:p+1,2);a31=y(2:p+1,3) ; % input 2 [y,x]=dstep(ad,bd,cd,dd,2,p+1); a12=y(2:p+1,1);a22=y(2:p+1,2);a32=y(2:p+1,3); [y,x]=dstep(ad,bd,cd,dd,3,p+1); a13=y(2:p+1,1);a23=y(2:p+1,2);a33=y(2:p+1,3); % this completes the step perturbations Next fill the dyanamic matrices pause % press any key A11=zeros(p,n); A12=A11;A13=A11;A21=A11;A22=A11;A23=A11;A31=A11;A32=A11;A33=A11; for i= 1:p for j=1:i if j <= i & j <= n A11(i,j)=a11(i-j+1); A12(i,j)=a12(i-j+1); A13(i,j)=a13(i-j+1); A21(i,j)=a21(i-j+1); A22(i,j)=a22(i-j+1); A23(i,j)=a23(i-j+1); A31(i,j)=a31(i-j+1); A32(i,j)=a32(i-j+1); A33(i,j)=a33(i-j+1); end; end ; end;