www.gusucode.com > mpc 案例源码 matlab代码程序 > mpc/RetrieveCustomConstraintsFromMPCControllerExample.m

    %% Retrieve Custom Constraints from MPC Controller
%%
% Create a third-order plant model with two manipulated variables, one
% measured disturbance, and two measured outputs.

% Copyright 2015 The MathWorks, Inc.

plant = rss(3,2,3);
plant.D = 0;
plant = setmpcsignals(plant,'mv',[1 2],'md',3);

%%
% Create an MPC controller for this plant.
MPCobj = mpc(plant,0.1);

%%
% Assume that you have two soft constraints.
%%
% 
% $$\begin{array}{l}
% {u_1} + {u_2} \le 5\\
% {y_2} + v \le 10
% \end{array}$$
% 


%% 
% Set the constraints for the MPC controller.
E = [1 1; 0 0];
F = [0 0; 0 1];
G = [5;10];
V = [1;1];
S = [0;1];
setconstraint(MPCobj,E,F,G,V,S)

%%
% Retrieve the constraints from the controller.
[E,F,G,V,S] = getconstraint(MPCobj)