www.gusucode.com > mpc 案例源码 matlab代码程序 > mpc/SpecifyCustomConstraintsOnInputsAndOutputsExample.m
%% Specify Custom Constraints on Linear Combination of Inputs and Outputs % Specify a constraint of the form $0 \le u_2 - 2u_3 + y_2 \le 15$ on an MPC % controller. %% % Create a third-order plant model with three manipulated variables and two % measured outputs. plant = rss(3,2,3); plant.D = 0; %% % Create an MPC controller for this plant. MPCobj = mpc(plant,0.1); %% % Formulate the constraint in the required form: %% % % $$\left[ \begin{array}{l} % \begin{array}{*{20}{c}} % 0&{ - 1}&2 % \end{array}\\ % \begin{array}{*{20}{c}} % 0&1&{ - 2} % \end{array} % \end{array} \right]\left[ {\begin{array}{*{20}{c}} % {{u_1}}\\ % {{u_2}}\\ % {{u_3}} % \end{array}} \right] + \left[ {\begin{array}{*{20}{c}} % 0&{ - 1}\\ % 0&1 % \end{array}} \right]\left[ {\begin{array}{*{20}{c}} % {{y_1}}\\ % {{y_2}} % \end{array}} \right] \le \left[ {\begin{array}{*{20}{c}} % 0\\ % {15} % \end{array}} \right] + \varepsilon \left[ {\begin{array}{*{20}{c}} % 1\\ % 1 % \end{array}} \right]$$ % %% % Specify the constraint matrices. E = [0 -1 2;0 1 -2]; F = [0 -1;0 1]; G = [0;15]; %% % Set the constraints in the MPC controller. setconstraint(MPCobj,E,F,G)