| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Model Predictive Control Toolbox |
| Contents | Index |
u=mpcmove(MPCobj,x,ym,r,v) computes the current input move u(k), given the current estimated extended state x(k), the vector of measured outputs ym(k), the reference vector r(k), and the measured disturbance vector v(k), by solving the quadratic programming problem based on the parameters contained in the MPC controller MPCobj.
x is an mpcstate object. It is updated by mpcmove through the internal state observer based on the extended prediction model (see getestim for details). A default initial state x for the first call at time k=0 can be simply defined as:
[u,Info]=mpcmove(MPCobj,x,ym,r,v) also returns the structure Info containing details about the optimal control calculations. Info has the following fields.
To plot the optimal input trajectory, type:
The optimal output and state trajectories can be plotted similarly. The input, output, and state sequences Uopt, Yopt, Xopt, Topt correspond to the predicted open-loop optimal control trajectories solving the optimization problem described in Optimization Problem. The optimal trajectories might also help understand the closed-loop behavior. For instance, constraints that are active in the open-loop optimal trajectory only at late steps of the prediction horizon might not be active at all in the closed-loop MPC trajectories. The sequence of optimal manipulated variable increments can be retrieved from MPCobj.MPCData.MPCstruct.optimalseq.
QPCode returns either 'feasible', 'infeasible' or 'unreliable' (the latter occurs when the QP solver terminates because the maximum number of iterations MPCobj.Optimizer.MaxIter is exceeded; see qpdantz). When QPCode='infeasible', then u is obtained by shifting the previous optimal sequence of manipulated variable rates (stored in MPCobj.MPCData.MPCstruct.optimalseq inside the MPC object MPCobj), and summing the first entry of this sequence to the previous vector of manipulated moves. You may set up different backup strategies for handling infeasible situations by discarding u and replacing it with a different emergency decision-variable vector.
r/v can be either a sample (no future reference/disturbance known in advance) or a sequence of samples (when a preview / look-ahead / anticipative effect is desired). In the latter case, they must be an array with as many rows as p and as many columns as the number of outputs/measured disturbances, respectively. If the number of rows is smaller than p, the last sample is extended constantly over the horizon, to obtain the correct size.
The default for y and r is MPCobj.Model.Nominal.Y. The default for v is obtained from MPCobj.Model.Nominal.U. The default for x is mpcstate(MPCobj,MPCobj.Model.Nominal.X,0,0,U0) where U0 are the entries from MPCobj.Model.Nominal.U corresponding to manipulated variables.
To bypass the MPC Controller block's internal estimator and use your own state observer to update the MPC state yourself, you can for instance use the syntax:
xp=x.plant; xd=x.dist; xn=x.noise; % Save current state
u=mpcmove(MPCobj,x,ym,r,v); % x will be updated
% Now call to your state update function:
[xp,xd,xn]=my_estimator(xp,xd,xn,ym); % States get updated
x.plant=xp;x.dist=xd;x.noise=xn;
Model predictive control of a multi-input single-output system (see the demo MPCMISO.M). The system has three inputs (one manipulated variable, one measured disturbance, one unmeasured disturbance) and one output.
% Open-loop system parameters % True plant and true initial state sys=ss(tf({1,1,1},{[1 .5 1],[1 1],[.7 .5 1]})); x0=[0 0 0 0 0]'; % MPC object setup Ts=.2; % sampling time % Define type of input signals sys.InputGroup=struct('Manipulated',1,'Measured',2,'Unmeasured', 3); % Define constraints on manipulated variable MV=struct('Min',0,'Max',1); Model=[]; % Reset structure Model Model.Plant=sys; % Integrator driven by white noise with variance=1000 Model.Disturbance=tf(sqrt(1000),[1 0]);
p=[]; % Prediction horizon (take default one) m=3; % Control horizon weights=[]; % Default value for weights MPCobj=mpc(Model,Ts,p,m,weights,MV); % Simulate closed loop system using MPCMOVE Tstop=30; %Simulation time xmpc=mpcstate(MPCobj); % Initial state of MPC controller x=x0; % Initial state of Plant r=1; % Output reference trajectory % State-space matrices of Plant model [A,B,C,D]=ssdata(c2d(sys,Ts)); YY=[];XX=[];RR=[]; for t=0:round(Tstop/Ts)-1, XX=[XX,x]; % Define measured disturbance signal v=0; if t*Ts>=10, v=1; end % Define unmeasured disturbance signal d=0; if t*Ts>=20, d=-0.5; end % Plant equations: output update % (note: no feedrthrough from MV to Y, D(:,1)=0) y=C*x+D(:,2)*v+D(:,3)*d; YY=[YY,y]; % Compute MPC law u=mpcmove(MPCobj,xmpc,y,r,v); % Plant equations: state update x=A*x+B(:,1)*u+B(:,2)*v+B(:,3)*d; end % Plot results plot(0:Ts:Tstop-Ts,YY);grid
mpc, mpcstate, sim, setestim, getestim
| Provide feedback about this page |
![]() | mpchelp | mpcprops | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |