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

    %% Design Controller Using Identified Model with Noise Channel  
% This example shows how to design a model predictive controller using an
% identified plant model with a nontrivial noise component. 
%
% This example requires a System Identification Toolbox(TM) license.   

% Copyright 2015 The MathWorks, Inc.


%% 
% Load the input/output data for identification. 
load dryer2
Ts = 0.08;

%%
% Create an |iddata| object from the input
dry_data = iddata(y2,u2,Ts);
dry_data_detrended = detrend(dry_data);

%%
% Estimate a linear state-space plant model.
plant_idss = ssest(dry_data_detrended,3); 

%%
% |plant_idss| is a third-order, identified state-space model that contains
% one measured input and one unmeasured  noise component.  

%% 
% Design a model predictive controller for the identified plant model. 
controller = mpc(plant_idss,Ts);

%%
% |controller| is an |mpc| object in which: 
%  
% * The measured input of |plant_idss| is a manipulated variable.
% * The noise component of |plant_idss| is an unmeasured disturbance.
% * The output of |plant_idss| is a measured output.   

%%
% To view the structure of the model predictive controller, at the MATLAB(R)
% command prompt, type |controller|.  

%% 
% You can change the treatment of plant input signals in one of two ways: 
%  
% * Programmatic - Use the |setmpcsignals| command to set the signal types.
% * MPC Designer - Specify the signal types when defining the MPC structure
% using an imported plant.

%% 
% You can also design a model predictive controller using: 
plant_ss = ss(plant_idss,'augmented');
controller2 = mpc(plant_ss,Ts); 

%%
% When you use the |'augmented'| input argument, |ss| creates two input
% groups, |Measured| and |Noise|, for the measured and noise inputs of |plant_idss|.
% |mpc| handles the measured and noise components of |plant_ss| and |plant_idss|
% identically.