echo on % Problem ch17 Problem 1 Using Mpccon & Mpcsim file % Kartik Arora Date:04-19-01. % Purpose: routines for step response models. % The plant considered is SISO with a SISO distrubance plant. % 2 inputs, 2 outputs system % Plant transfer function: g11 = 12.8exp(-s)/(16.7s+1); % g12 = -18.9exp(-3s)/(21.0s+1); % g21 = 6.6exp(-7s)/(10.9s+1); % g22 = -19.4exp(-3s)/(14.4s+1); % % Build the step response models for as sampling period of 2. % echo off clear delt1=0; delay1=1; num1=12.8; den1=[16.7 1]; g11 = poly2tfd(num1,den1,delt1,delay1); delay2=7; num2=6.6; den2=[10.9 1]; g21=poly2tfd(num2,den2,delt1,delay2); delay3=3; num3=-18.9; den3=[21.0 1]; g12=poly2tfd(num3,den3,delt1,delay3); delay4=3; num4=-19.4; den4=[14.4 1]; g22=poly2tfd(num4,den4,delt1,delay4); % tfinal =84; delt=2; nout1 = 2; plant1 = tfd2step(tfinal,delt,nout1,g11,g21,g12,g22); % % % Calculate the MPC controller gain matrix for % No plant/model mismatch, % Output Weight = 1, Input Weight = 0 % Input Horizon = 2, Output Horizon = 20 model1 = plant1; ywt = [1 1]; uwt = [0 0]; M = 2; P = 20; Kmpc1 = mpccon(model1,ywt,uwt,M,P); % % Simulate and plot response for unmeasured and measured % step disturbance through dplant. tend = 50; r = [0 1]; dmodel = []; dstep = 0.0; [y1,u1] = mpcsim(model1,model1,Kmpc1,tend,r); plotall([y1],[u1],delt);