compare - Compare model output and measured output

Syntax

compare(data,m);
compare(data,m,k)
compare(data,m,k,'Samples',sampnr,'InitialState',init,'OutputPlots
',Yplots)
compare(data,m1,m2,...,mN)
compare(data,m1,'PlotStyle1',...,mN,'PlotStyleN')
[yh,fit,x0] = compare(data,m1,'PlotStyle1',...,mN,'PlotStyleN',k)

Description

data is the output-input data in the usual iddata object format. data can also be an idfrd object with frequency-response data.

compare computes the output yh that results when the model m is simulated with the input u. m can be any idmodel or idnlmodel model object. The result is plotted together with the corresponding measured output y. The percentage of the output variation that is explained by the model

fit = 100*(1 - norm(yh - y)/norm(y-mean(y))) 

is also computed and displayed. For multiple-output systems, this is done separately for each output. For frequency-domain data (or in general for complex valued data) the fit is still calculated as above, but only the absolute values of y and yh are plotted.

When the argument k is specified, the k step-ahead prediction of y according to the model m are computed instead of the simulated output. In the calculation of , the model can use outputs up to time : , , … (and inputs up to the current time t). The default value of k is inf, which gives a pure simulation from the input only. Note that for frequency-domain data, only simulation (k = inf) is allowed, and for time-series data (no input) only prediction (k not inf) is possible.

Property Name/Property Value Pairs

The optional property name/property value pairs 'Samples'/sampnr, 'InitialState'/init, and 'OutputPlots'/Yplots can be given in any order.

The argument Yplots can be a cell array of strings. Only the outputs with OutputName in this array are plotted, while all are used for the necessary computations. If Yplots is not specified, all outputs are plotted.

The argument sampnr indicates that only the sample numbers in this row vector are plotted and used for the calculation of the fit. The whole data record is used for the simulation/prediction.

The argument init determines how to handle initial conditions in the models:

Several Models

When several models are specified, as in compare(data,m1,m2,...,mN), the plots show responses and fits for all models. In that case data should contain all inputs and outputs that are required for the different models. However, some models might correspond to subselections of channels and might not need all channels in data. In that case the proper handling of signals is based on the InputNames and OutputNames of data and the models.

With compare(data,m1,'PlotStyle1',...mN,'PlotStyle2'), the color, line style, and/or marker can be specified for the curves associated with the different models. The markers are the same as for the regular plot command. For example,

compare(data,m1,'g_*',m2,'r:')

If data contains several experiments, separate plots are given for the different experiments. In this case sampnr, if specified, must be a cell array with as many entries as there are experiments.

Arguments

When output arguments [yh,fit,x0] = compare(data,m1,..,mN) are specified, no plots are produced.

yh is a cell array of length equal to the number of models. Each cell contains the corresponding model output as an iddata object.

fit is, in the general case, a 3-D array with fit(kexp,kmod,ky) containing the fit (computed as above) for output ky, model kmod, and experiment kexp.

x0 is a cell array, such that x0{kmod} is the estimated initial state for model number kmod. If data is multiexperiment, X0{kmod} is a matrix whose column number kexp is the initial state vector for experiment number kexp.

Examples

Split the data record into two parts. Use the first one for estimating a model and the second one to check the model's ability to predict six steps ahead.

ze = z(1:250);
zv = z(251:500);
m= armax(ze,[2 3 1 0]);
compare(zv,m,6);
compare(zv,m,6,'Init','z') % No estimation of 
                           % the initial state.

See Also

pe 
predict 
sim 

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS