Compare measured outputs with model outputs.
Syntax
compare(z,th);
[yh,fit] = compare(z,th,k,sampnr,leveladj)
Description
z is the output-input data in the usual format
z = [y u]
where y is a matrix whose r-th column is the r-th output signal and correspondingly for the input u. compare computes the output yh that results when the model th is simulated with the input u. The result is plotted (yellow/solid) together with the corresponding measured output y (magenta/dashed). The mean square fit
fit = norm(yh - y)/sqrt(length(y))
is also computed and displayed. For multi-output systems this is done separately for each output. Pressing the Return key advances the plots.
The argument k computes the k-step ahead prediction of y according to the model th 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 obtains a pure simulation from the input only.
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, though. If the optional argument leveladj is set to 'yes', the simulated/predicted output and the measured output are level adjusted so that they both start at level zero. (This applies also to the calculation of the fit.) This allows for discounting of drift phenomena in the data.
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,:);
th = armax(ze,[2 3 1 0]);
compare(zv,th,6);
See Also
idsim, predict
[ Previous | Help Desk | Next ]