Quantcast

Documentation Center

  • Trial Software
  • Product Updates

compare

Compare model output and measured output

Syntax

compare(data,sys)
compare(data,sys,prediction_horizon)
compare(data,sys,style,prediction_horizon)
compare(data,sys1,...,sysN,prediction_horizon)
compare(data,sys1,style1,...,sysN,styleN,prediction_horizon)
compare(___,opt)
[y,fit,x0] = compare(___)

Description

compare(data,sys) plots the simulated response of a dynamic system model, sys, superimposed over validation data, data, for comparison. The plot also displays the normalized root mean square (NRMSE) measure of the goodness of the fit.

The matching of the input/output channels in data and sys is based on the channel names. Thus, it is possible to evaluate models that do not use all the input channels that are available in data.

compare(data,sys,prediction_horizon) compares the predicted response of sys to the measured response in data. Measured output values in data up to time t-prediction_horizon are used to predict the output of sys at time t.

compare(data,sys,style,prediction_horizon) uses style to specify the line type, marker symbol, and color.

compare(data,sys1,...,sysN,prediction_horizon) compares multiple dynamic systems responses on the same axes. compare automatically chooses colors and line styles in the order specified by the ColorOrder and LineStyleOrder properties of the current axes.

compare(data,sys1,style1,...,sysN,styleN,prediction_horizon) compares multiple systems responses on the same axes using the line type, marker symbol, and color specified for each system.

compare(___,opt) configures the comparison using an option set, opt.

[y,fit,x0] = compare(___) returns the model response, y, goodness of fit value, fit, and the initial states, x0. No plot is generated.

Input Arguments

data

Validation data.

Specify data as either an iddata or idfrd object.

If sys is an iddata object, then data must be an iddata object with matching domain, number of experiments and time or frequency vectors.

If sys is a frequency response model (idfrd or frd), then data must be a frequency response model too.

data can represent either time- or frequency-domain data when comparing with linear models. data must be time-domain data when comparing with a nonlinear model.

For frequency domain data, the real and imaginary parts of the corresponding frequency functions are shown in separate axes.

When data is an FRD model, the frequency responses of data and sys are plotted.

sys

iddata object or dynamic system model.

When the time or frequency units of data do not match those of sys, sys is rescaled to match the units of data.

prediction_horizon

Prediction horizon.

Specify prediction_horizon as Inf to obtain a pure simulation of the system.

prediction_horizon is ignored when sys is an iddata object, an FRD model or a dynamic system with no noise component. prediction_horizon is also ignored when using frequency response validation data.

For time-series models, use a finite value for prediction_horizon.

Default: Inf

style

Line style, marker, and color of both the linear and marker, specified as a one-, two-, or three-part string enclosed in single quotes (' '). The elements of the string can appear in any order. The string can specify only the line style, the marker, or the color.

For more information about configuring the style string, see Specify Line Style, Color, and Markers in the MATLAB® documentation.

opt

Comparison option set.

opt is an option set created using compareOptions, which specifies options including:

  • Handling of initial conditions

  • Sample range for computing fit numbers

  • Data offsets

  • Output weighting

Output Arguments

y

Model response.

Measured output values in data up to time t = t-prediction_horizon are used to predict the output of sys at time t.

For multimodel comparisons, y is a cell array, with one entry for each input model.

For multiexperiment data, y is a cell array, with one entry for each experiment.

For multimodel comparisons using multiexperiment data, y is an Nsys-by-Nexp cell array. Nsys is the number of models, and Nexp is the number of experiments.

If sys is a model array, then y is an array, with an entry corresponding to each model in sys and experiment in data.

fit

NRMSE fitness value.

The fit is calculated (in percentage) using:

where y is the validation data output and is the output of sys.

For FRD models, fit is calculated by comparing the complex frequency response. The magnitude and phase curves shown in the plot are not compared separately.

If data is an iddata object, fit is an Ny-by-1 vector, where Ny is the number of outputs.

If data is an FRD model with Ny outputs and Nu inputs, fit is an Ny-by-Nu matrix. Each entry of fit corresponds to an input/output pair in sys.

For multimodel comparisons, fit is a cell array, with one entry for each input model.

For multiexperiment data, fit is a cell array, with one entry for each experiment.

For multimodel comparisons using multiexperiment data, fit is an Nsys-by-Nexp cell array. Nsys is the number of models, and Nexp is the number of experiments.

x0

Initial conditions used to compute system response.

When sys is an frd or iddata object, x0 is [].

For multimodel comparisons, x0 is a cell array, with one entry for each input model.

For multiexperiment data, x0 is a cell array, with one entry for each experiment.

For multimodel comparisons using multiexperiment data, x0 is an Nsys-by-Nexp cell array. Nsys is the number of models, and Nexp is the number of experiments.

Examples

expand all

Compare Estimated Model to Measured Data

Estimate a state-space model for measured data.

load iddata1 z1;
sys = ssest(z1,3);

sys, an idss model, is a continuous-time state-space model.

Compare the predicted output for 10 steps ahead to the measured output.

prediction_horizon = 10;
compare(z1,sys,prediction_horizon);

Compare Multiple Estimated Models to Measured Data

Compare the outputs of multiple estimated models, of differing types, to measured data.

This example compares the outputs of an estimated process model and an estimated Output-Error polynomial model to measured data.

Estimate a process model and an Output-Error polynomial for frequency response data.

load demofr  % frequency response data
zfr = AMP.*exp(1i*PHA*pi/180);
Ts = 0.1;
data = idfrd(zfr,W,Ts);
sys1 = procest(data,'P2UDZ');
sys2 = oe(data,[2 2 1]);

sys1, an idproc model, is a continuous-time process model. sys2, an idpoly model, is a discrete-time Output-Error model.

Compare the frequency response of the estimated models to data.

compare(data,sys1,'g',sys2,'r');

Compare Estimated Model to Data and Specify Comparison Options

Compare an estimated model to measured data. Specify that the initial conditions be estimated such that the prediction error of the observed output is minimized.

Estimate a transfer function for measured data.

load iddata1 z1;
sys = tfest(z1,3);

sys, an idtf model, is a continuous-time transfer function model.

Create an option set to specify the initial condition handling.

opt = compareOptions('InitialCondition','e');

Compare the estimated transfer function model's output to the measured data using the comparison option set.

compare(z1,sys,opt);

See Also

| | | | | | | | |

Was this topic helpful?