% True plant & true initial state gpnum=[ 4.05]; gpden=[ 50 1]; sys1=ss(tf(gpnum,gpden , 'InputDelay',27)); gdnum=[ 1.20]; gdden=[ 45 1]; sys2=ss(tf(gdnum,gdden , 'InputDelay',27)); sys=[sys1 sys2]; % Initial state x0=[0 0]'; Ts=5; %Sample time Tstop=300; %Simulation time model=c2d(sys,Ts); % prediction model p=30; % output horizon moves=4; % Control move horizon umin=-Inf; umax=Inf; dumin=-Inf; dumax=Inf; ymin=-Inf; ymax=Inf; % output limits limits={umin,umax,dumin,dumax,ymin,ymax}; weights={[0],[1],[1]}; clear MPCadd MPCadd.mvindex=[1]; MPCadd.mdindex=[2]; open_system('ch17ex3.mdl') sim('ch17ex3',Tstop)