Main Content

Hammerstein-Wiener models describe dynamic systems using one or two static nonlinear blocks in series with a linear block. The linear block is a discrete transfer function and represents the dynamic component of the model. For more information about the structure of these models, see What are Hammerstein-Wiener Models?

You can estimate Hammerstein-Wiener models in the **System Identification** app or at the command line using the `nlhw`

command. To estimate a Hammerstein-Wiener model, you first prepare
the estimation data. You then configure the model structure and estimation algorithm,
and then perform estimation. After estimation, you can validate the estimated model as
described in Validating Hammerstein-Wiener Models.

You can use only uniformly sampled time-domain input-output data for estimating Hammerstein-Wiener models. Your data can have one or more input and output channels. You cannot use time series data (output only) or frequency-domain data for estimation. Use nonlinear ARX or nonlinear grey-box models for time series data.

To prepare the data for model estimation, import your data into
the MATLAB^{®} workspace, and do *one* of the
following:

**In the System Identification app**— Import data into the app, as described in Represent Data.**At the command line**— Represent your data as an`iddata`

object.

After importing the data, you can analyze data quality and preprocess data by interpolating missing values, filtering to emphasize a specific frequency range, or resampling using a different sample time. For more information, see Ways to Prepare Data for System Identification. For most applications, you do not need to remove offsets and linear trends from the data before nonlinear modeling. However, data detrending can be useful in some cases, such as before modeling the relationship between the change in input and output about an operating point.

After preparing your estimation data, you can configure your model structure, loss function, and estimation algorithm, and then estimate the model using the estimation data.

The Hammerstein-Wiener model structure consists of input and output nonlinear blocks in series with a linear block. The linear block is a discrete transfer function and represents the dynamic component of the model.

To configure the structure of a Hammerstein-Wiener model:

**Configure the linear transfer function block.**Perform

*one*of the following:Specify model order and input delay for the linear transfer function as:

*nb*— Number of zeros plus one.*nb*is the length of the numerator (*B*) polynomial.*nf*— Number of poles.*nf*is the order of the transfer function denominator (*F*polynomial).*nk*— Delay from input to the output in terms of the number of samples.

For MIMO systems with

*Ny*outputs and*Nu*inputs,*nb*,*nf*, and*nk*are*Ny*-by-*Nu*matrices.Initialize the linear block using a discrete-time linear model — You can initialize using linear models at the command line only. The initialization sets the transfer function of the linear block to that of the specified linear model. For more information, see Initialize Hammerstein-Wiener Estimation Using Linear Model.

**Configure the input and output nonlinearities,***f*and*h*respectively.The default input and output nonlinearity estimators are piecewise linear functions. See the

`idPiecewiseLinear`

reference page for more information. To configure the input and output nonlinearity estimators:Choose the type of input and output nonlinearity estimators, and configure their properties.

For a list of available nonlinearity estimators, see Available Nonlinearity Estimators for Hammerstein-Wiener Models.

Exclude the input or output nonlinear block.

You do not have to include both the input and the output nonlinearity in the model structure. When a model contains only the input nonlinearity

*f*, it is called a*Hammerstein*model. Similarly, when the model contains only the output nonlinearity*h*, it is called a*Wiener*model.

For information about how to configure the model structure at the command line and in the app, see Estimate Hammerstein-Wiener Models at the Command Line and Estimate Hammerstein-Wiener Models in the App.

To configure the model estimation, specify the loss function to be minimized, and choose the estimation algorithm and other estimation options to perform the minimization.

The loss function or cost function is a function of the error between the model output and the measured output. For more information about loss functions, see Loss Function and Model Quality Metrics.

At the command line, use the `nlhw`

option set, `nlhwOptions`

to configure your loss
function. You can specify the following options:

`OutputWeight`

— Specify a weighting of the error in multi-output estimations.`Regularization`

— Modify the loss function to add a penalty on the variance of the estimated parameters. For more information, see Regularized Estimates of Model Parameters.

For details about how to specify these options in the app, see Estimate Hammerstein-Wiener Models in the App.

To estimate a Hammerstein-Wiener model, the software uses iterative search
algorithms to minimize the loss function. At the command line, use
`nlhwOptions`

to specify the search algorithm and other
estimation options. Some of the options you can specify are:

`SearchMethod`

— Search method for minimization of prediction or simulation errors, such as Gauss-Newton and Levenberg-Marquardt line search, and Trust-region reflective Newton approach.`SearchOptions`

— Option set for the search algorithm, with fields that depend on the value of`SearchMethod`

, such as:`MaxIterations`

— Maximum number of iterations to perform.`Tolerance`

— Condition for terminating iterative search when the expected improvement of the parameter values is less than a specified value.

`InitialCondition`

— By default, the software treats the initial states of the model as zero and does not estimate the states. You can choose to estimate initial states, which sometimes can improve parameter estimates.

To see a complete list of available estimation options, see `nlhwOptions`

. For details about how
to specify these estimation options in the app, see Estimate Hammerstein-Wiener Models in the App.

After preprocessing the estimation data and configuring the model structure,
loss function, and estimation options, you can estimate the model in the **System Identification** app, or using
`nlhw`

. The resulting model is an
`idnlhw`

object that stores all
model data, including model parameters and nonlinearity estimator. For more
information about these model objects, see Nonlinear Model Structures. You can
validate the estimated model as described in Validating Hammerstein-Wiener Models.

At the command line, you can use one of the following linear models to initialize the linear block of a Hammerstein-Wiener model:

Polynomial model of Output-Error (OE) structure (

`idpoly`

)State-space model with no disturbance component (

`idss`

model with K = 0)Transfer function (

`idtf`

model)

Typically, you use the `oe`

, `n4sid`

, or `tfest`

commands to obtain the linear
model. You can provide the linear model when constructing or estimating a
Hammerstein-Wiener model. For example, use the following syntax to estimate a
Hammerstein-Wiener model using estimation data and a linear model
`LinModel`

.

m = nlhw(data,LinModel)

Here `m`

is an `idnlhw`

object, and
`data`

is a time-domain `iddata`

object. The software uses
the linear model for initializing the Hammerstein-Wiener estimation by:

Assigning the linear model orders as initial values of nonlinear model orders (

`nb`

and`nf`

properties of the Hammerstein-Wiener (`idnlhw`

) and delays (`nk`

property).Setting the

*B*and*F*polynomials of the linear transfer function in the Hammerstein-Wiener model structure.

During estimation, the estimation algorithm uses these values to adjust the
nonlinear model to the data. By default, both the input and output nonlinearity
estimators are piecewise linear functions (see `idPiecewiseLinear`

).

You can also specify different input and output nonlinearity estimators. For example, a sigmoid network input nonlinearity estimator and a dead-zone output nonlinearity estimator.

m = nlhw(data,LinModel,'idSigmoidNetwork','idDeadZone')

For an example, see Estimate Hammerstein-Wiener Models Initialized Using Linear OE Models.