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

    %% Specify Fixed Parameters for 2-D Plot of Explicit Control Law
%%
% Define a double integrator plant model and create a traditional implicit 
% MPC controller for this plant. Constrain the manipulated variable to have
% an absolute value less than |1|.

% Copyright 2015 The MathWorks, Inc.

plant = tf(1,[1 0 0]);
MPCobj = mpc(plant,0.1,10,3);
MPCobj.MV = struct('Min',-1,'Max',1);

%%
% Define the parameter bounds for generating an explicit MPC controller.
range = generateExplicitRange(MPCobj);
range.State.Min(:) = [-10;-10];
range.State.Max(:) = [10;10];
range.Reference.Min(:) = -2;
range.Reference.Max(:) = 2;
range.ManipulatedVariable.Min(:) = -1.1;
range.ManipulatedVariable.Max(:) = 1.1;

%%
% Create an explicit MPC controller.
EMPCobj = generateExplicitMPC(MPCobj,range);

%%
% Create a default plot parameter structure, which specifies that all of the
% controller parameters are fixed at their nominal values for plotting.
plotParams = generatePlotParameters(EMPCobj);

%%
% Allow the controller states to vary when creating a plot.
plotParams.State.Index = [];
plotParams.State.Value = [];

%%
% Fix the manipulated variable and reference signal to |0| for plotting.
plotParams.ManipulatedVariable.Index(1) = 1;
plotParams.ManipulatedVariable.Value(1) = 0;
plotParams.Reference.Index(1) = 1;
plotParams.Reference.Value(1) = 0;

%%
% Generate the 2-D section plot for the explicit MPC controller.
plotSection(EMPCobj,plotParams)