# compareOptions

Option set for `compare`

## Description

Use a `compareOptions`

object to specify options for comparing
identified model output with measured output through the `compare`

function. You can specify options such as the handling of initial
conditions or the output weight to be used in estimation.

## Creation

## Properties

`Samples`

— Data for which `compare`

calculates fit values

vector | cell array

`compare`

Specify `Samples`

as a vector containing the data sample indices.
For multiexperiment data, use a cell array of *Ne* vectors, where
*Ne* is the number of experiments.

`InitialCondition`

— Handling of initial conditions

`'e'`

(default) | `'z'`

Handling of initial conditions.

Specify `InitialCondition`

as one of the following:

`'z'`

— Zero initial conditions.`'e'`

— Estimate initial conditions such that the prediction error for observed output is minimized.For nonlinear grey-box models, only those initial states

`i`

that are designated as free in the model (`sys.InitialStates(i).Fixed = false`

) are estimated. To estimate all the states of the model, first specify all the`Nx`

states of the`idnlgrey`

model`sys`

as free.for i = 1:Nx sys.InitialStates(i).Fixed = false; end

Similarly, to fix all the initial states to values specified in

`sys.InitialStates`

, first specify all the states as fixed in the`sys.InitialStates`

property of the nonlinear grey-box model.`'d'`

— Similar to`'e'`

, but absorbs nonzero delays into the model coefficients. The delays are first converted to explicit model states, and the initial values of those states are also estimated and returned.Use this option for linear models only.

Vector or Matrix — Initial guess for state values, specified as a numerical column vector of length equal to the number of states. For multiexperiment data, specify a matrix with

*Ne*columns, where*Ne*is the number of experiments. Otherwise, use a column vector to specify the same initial conditions for all experiments. Use this option for state-space (`idss`

and`idgrey`

) and nonlinear models (`idnlarx`

,`idnlhw`

, and`idnlgrey`

) only.`initialCondition`

object —`initialCondition`

object that represents a model of the free response of the system to initial conditions. For multiexperiment data, specify a 1-by-*N*array of objects, where_{e}*N*is the number of experiments._{e}Use this option for individual linear models only. If you are analyzing more than one model and want to specify an

`initialCondition`

object for each model, you must specify the object and use`compare`

for each model separately.Structure with the following fields, which contain the historical input and output values for a time interval immediately before the start time of the data used by

`compare`

:Field Description `Input`

Input history, specified as a matrix with *Nu*columns, where*Nu*is the number of input channels. For time series models, use`[]`

. The number of rows must be greater than or equal to the model order.`Output`

Output history, specified as a matrix with *Ny*columns, where*Ny*is the number of output channels. The number of rows must be greater than or equal to the model order.For multiexperiment data, configure the initial conditions separately for each experiment by specifying

`InitialCondition`

as a structure array with*Ne*elements. To specify the same initial conditions for all experiments, use a single structure.The software uses

`data2state`

to map the historical data to states. If your model is not`idss`

,`idgrey`

,`idnlgrey`

, or`idnlarx`

, the software first converts the model to its state-space representation and then maps the data to states. If conversion of your model to`idss`

is not possible, the estimated states are returned empty.`x0obj`

— Specification object created using`idpar`

. Use this object for discrete-time state-space (`idss`

and`idgrey`

) and nonlinear grey-box (`idnlgrey`

) models only. Use`x0obj`

to impose constraints on the initial states by fixing their value or specifying minimum or maximum bounds.

`InputInterSample`

— Input-channel intersample behavior

`'auto'`

| `'zoh'`

| `'foh'`

| `'bl'`

Input-channel intersample behavior for transformations between discrete time and
continuous time, specified as `'auto'`

,
`'zoh'`

,`'foh'`

, or `'bl'`

.

The definitions of the three behavior values are as follows:

`'zoh'`

— Zero-order hold maintains a piecewise-constant input signal between samples.`'foh'`

— First-order hold maintains a piecewise-linear input signal between samples.`'bl'`

— Band-limited behavior specifies that the continuous-time input signal has zero power above the Nyquist frequency.

`iddata`

objects have a similar property,
`data.InterSample`

, that contains the same behavior value options.
When the `InputInterSample`

value is `'auto'`

and
the estimation data is in an `iddata`

object `data`

, the
software uses the `data.InterSample`

value. When the estimation data
is instead contained in a timetable or a matrix pair, with the `'auto'`

option, the software uses `'zoh'`

.

The software applies the same option value to all channels and all experiments.

`InputOffset`

— Removes offset from time domain input data for model response computation

`[]`

(default) | vector | matrix

Specify as a column vector of length *Nu*, where
*Nu* is the number of inputs.

Use `[]`

to indicate no offset.

For multiexperiment data, specify `InputOffset`

as a
*Nu*-by-*Ne* matrix. *Nu* is the
number of inputs and *Ne* is the number of experiments.

Each entry specified by `InputOffset`

is subtracted from the
corresponding input data.

`OutputOffset`

— Removes offset from time-domain output data for model response prediction

`[]`

(default) | vector | matrix

Specify as a column vector of length *Ny*, where
*Ny* is the number of outputs.

Use `[]`

to indicate no offset.

For multiexperiment data, specify `OutputOffset`

as a
*Ny*-by-*Ne* matrix. *Ny* is the
number of outputs and *Ne* is the number of experiments.

Each entry specified by `OutputOffset`

is subtracted from the
corresponding output data before computing the model response. After computing the model
response, the software adds the offset to the response to give the final model
response.

`OutputWeight`

— Weight of output for initial condition estimation

`[]`

(default) | `'noise'`

| matrix of doubles

`OutputWeight`

requires one of the following values:

`[]`

— No weighting is used. This option is the same as using`eye(Ny)`

for the output weight.*Ny*is the number of outputs.`'noise'`

— Inverse of the noise variance stored with the model.Matrix of doubles — A positive semi-definite matrix of dimension

*Ny*-by-*Ny*.*Ny*is the number of outputs.

## Examples

### Create Default Options Set for Model Comparison

### Specify Options for Model Comparison

Create an options set for `compare`

using zero initial conditions. Set the input offset to 5.

opt = compareOptions('InitialCondition','z','InputOffset',5);

Alternatively, use dot notation to set the values of `opt`

.

```
opt = compareOptions;
opt.InitialCondition = 'z';
opt.InputOffset = 5;
```

## Version History

**Introduced in R2012a**

### R2022b: `InputInterSample`

option allows intersample behavior specification for continuous models estimated from timetables or matrices.

`iddata`

objects contain an `InterSample`

property that
describes the behavior of the signal between sample points. The
`InputInterSample`

option implements a version of that property in
`compareOptions`

so that intersample behavior can be specified also when
estimation data is stored in timetables or matrices.

## See Also

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)