www.gusucode.com > ident 案例代码 matlab源码程序 > ident/PlotPredictedOutputForMultipleModelsExample.m

    %% Plot Predicted Output for Multiple Models
%%
% Load the estimation data.
load iddata1;
data = z1;
%%
% Estimate an ARX model of order [2 2 1].
sys1 = arx(data,[2 2 1]);
%%
% Estimate a transfer function with 2 poles.
 sys2 = tfest(data,2);
%%
% Create a |predict| option set to specify zero initial conditions for 
% prediction.
opt = predictOptions('InitialCondition','z');

%%
% Plot the predicted outputs for the estimated models. Use the specified
% prediction option set, |opt|, and specify prediction horizon as 10.
% Specify line styles for plotting the predicted output of each system.
%%
predict(sys1,'r--',sys2,'b',data,10,opt);
%%
% To change the display options, right-click the plot to 
% access the context menu. For example, to view the estimation data,
% select *Show Validation Data* from the context menu. To view the
% prediction error, select *Prediction Error Plot*.
%%
% You can also plot the predicted response using the |compare| command. 
% To do so, first create an option set for |compare| to specify the use of 
% zero initial conditions. 
opt = compareOptions('InitialCondition','z');
compare(data,sys1,'r--',sys2,'b',10,opt);