Main Content

# idnlhw

Hammerstein-Wiener model

## Syntax

sys = idnlhw(Orders)
sys = idnlhw(Orders,InputNL,OutputNL)
sys = idnlhw(Orders,InputNL,OutputNL,Name,Value)
sys = idnlhw(LinModel)
sys = idnlhw(LinModel,InputNL,OutputNL)
sys = idnlhw(LinModel,InputNL,OutputNL,Name,Value)

## Description

sys = idnlhw(Orders) creates a Hammerstein-Wiener model with the specified orders, and using piecewise linear functions as input and output nonlinearity estimators.

sys = idnlhw(Orders,InputNL,OutputNL) uses InputNL and OutputNL as the input and output nonlinearity estimators, respectively.

sys = idnlhw(Orders,InputNL,OutputNL,Name,Value) specifies additional attributes of the idnlhw model structure using one or more Name,Value pair arguments.

sys = idnlhw(LinModel) uses a linear model LinModel to specify the model orders and default piecewise linear functions for the input and output nonlinearity estimators.

sys = idnlhw(LinModel,InputNL,OutputNL) specifies input and output nonlinearity estimators for the model.

sys = idnlhw(LinModel,InputNL,OutputNL,Name,Value) specifies additional attributes of the idnlhw model structure using one or more Name,Value pair arguments.

## Object Description

idnlhw represents a Hammerstein-Wiener model. The Hammerstein-Wiener structure represents a linear model with input-output nonlinearities.

Use the nlhw command to both construct an idnlhw object and estimate the model parameters.

You can also use the idnlhw constructor to create the Hammerstein-Wiener model and then estimate the model parameters using nlhw.

For idnlhw object properties, see Properties.

## Examples

collapse all

Create a Hammersein-Wiener model with nb and nf = 2 and nk = 1.

m = idnlhw([2 2 1]);

m has piecewise linear input and output nonlinearity.

m = idnlhw([2 2 1],'sigmoidnet','deadzone');

The above is equivalent to:

m = idnlhw([2 2 1],'sig','dead');

The specified nonlinearities have a default configuration.

m = idnlhw([2 2 1],sigmoidnet('num',5),deadzone([-1,2]),'InputName','Volts','OutputName','Time');

Create a Wiener model (no input nonlinearity).

m = idnlhw([2 2 1],[],'saturation');

Estimate the model.

load iddata1;
m = nlhw(z1,m);

Construct an input-output polynomial model of OE structure.

B = [0.8 1];
F = [1 -1.2 0.5];
LinearModel = idpoly(1,B,1,1,F,'Ts',0.1);

Construct Hammerstein-Wiener model using OE model as its linear component.

m1 = idnlhw(LinearModel,'saturation',[],'InputName','Control');

## Input Arguments

collapse all

Order and delays of the linear subsystem transfer function, specified as a [nb nf nk] vector.

Dimensions of Orders:

• For a SISO transfer function, Orders is a vector of positive integers.

nb is the number of zeros plus 1, nf is the number of poles, and nk is the input delay.

• For a MIMO transfer function with nu inputs and ny outputs, Orders is a vector of matrices.

nb, nf, and nk are ny-by-nu matrices whose i-jth entry specifies the orders and delay of the transfer function from the jth input to the ith output.

Input static nonlinearity estimator, specified as one of the following.

 'pwlinear' or pwlinear object (default) Piecewise linear function 'sigmoidnet' or sigmoidnet object Sigmoid network 'wavenet' or wavenet object Wavelet network 'saturation' or saturation object Saturation 'deadzone' or deadzone object Dead zone 'poly1d' or poly1d object One-dimensional polynomial 'unitgain' or [] or unitgain object Unit gain customnet object Custom network — Similar to sigmoidnet, but with a user-defined replacement for the sigmoid function.

Specifying a character vector, for example 'sigmoidnet', creates a nonlinearity estimator object with default settings. Use object representation instead to configure the properties of a nonlinearity estimator.

InputNL = wavenet;
InputNL.NumberOfUnits = 10;

Alternatively, use the associated input nonlinearity estimator function with Name-Value pair arguments.

InputNL = wavenet('NumberOfUnits',10);

For nu input channels, you can specify nonlinear estimators individually for each input channel by setting InputNL to an nu-by-1 array of nonlinearity estimators.

InputNL = [sigmoidnet('NumberofUnits',5); deadzone([-1,2])]
To specify the same nonlinearity for all inputs, specify a single input nonlinearity estimator.

Output static nonlinearity estimator, specified as one of the following:

 'pwlinear' or pwlinear object (default) Piecewise linear function 'sigmoidnet' or sigmoidnet object Sigmoid network 'wavenet' or wavenet object Wavelet network 'saturation' or saturation object Saturation 'deadzone' or deadzone object Dead zone 'poly1d' or poly1d object One-dimensional polynomial 'unitgain' or [] or unitgain object Unit gain customnet object Custom network — Similar to sigmoidnet, but with a user-defined replacement for the sigmoid function.

Specifying a character vector creates a nonlinearity estimator object with default settings. Use object representation instead to configure the properties of a nonlinearity estimator.

OutputNL = sigmoidnet;
OutputNL.NumberOfUnits = 10;

Alternatively, use the associated input nonlinearity estimator function with Name-Value pair arguments.

OutputNL = sigmoidnet('NumberOfUnits',10);

For ny output channels, you can specify nonlinear estimators individually for each output channel by setting OutputNL to an ny-by-1 array of nonlinearity estimators. To specify the same nonlinearity for all outputs, specify a single output nonlinearity estimator.

Discrete-time linear model used to specify the linear subsystem, specified as one of the following:

• Input-output polynomial model of Output-Error (OE) structure (idpoly)

• State-space model with no disturbance component (idss with K = 0)

• Transfer function model (idtf)

Typically, you estimate the model using oe, n4sid, or tfest.

### Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Use Name,Value arguments to specify additional properties of idnlhw models during model creation. For example, m = idnlhw([2 3 1],'pwlinear','wavenet','InputName','Volts','Ts',0.1) creates an idnlhw model object with input nonlinearity estimator 'pwlinear', output nonlinearity estimator 'wavenet', input name Volts, and a sample time of 0.1 seconds.

## Properties

idnlhw object properties include:

nb, nf, nk

Model orders and delays of the linear subsystem transfer function, where nb is the number of zeros plus 1, nf is the number of poles, and nk is the input delay.

For a MIMO transfer function with nu inputs and ny outputs, nb, nf, and nk are ny-by-nu matrices whose i-jth entry specifies the orders and delay of the transfer function from the jth input to the ith output.

B

B polynomial of the linear block in the model structure, specified as a cell array of ny-by-nu elements, where ny is the number of outputs and nu is the number of inputs. An element B{i,j} is a row vector representing the numerator polynomial for the jth input to ith output transfer function. The element contains nk leading zeros, where nk is the number of input delays.

F

F polynomial of the linear block in the model structure, specified as a cell array of ny-by-nu elements, where ny is the number of outputs and nu is the number of inputs. An element F{i,j} is a row vector representing the denominator polynomial for the jth input to ith output transfer function.

InputNonlinearity

Input nonlinearity estimator, specified as one of the following:

 'pwlinear' or pwlinear object (default) Piecewise linear function 'sigmoidnet' or sigmoidnet object Sigmoid network 'wavenet' or wavenet object Wavelet network 'saturation' or saturation object Saturation 'deadzone' or deadzone object Dead zone 'poly1d' or poly1d object One- dimensional polynomial 'unitgain' or [] or unitgain object Unit gain customnet object Custom network

Specifying a character vector creates a nonlinearity estimator object with default settings. Use object representation instead to configure the properties of a nonlinearity estimator.

InputNonlinearity = wavenet;
InputNonlinearity.NumberOfUnits = 10;

Alternatively, use the associated input nonlinearity estimator function with Name-Value pair arguments.

InputNonlinearity = wavenet('NumberOfUnits',10);

For nu input channels, you can specify nonlinear estimators individually for each input channel by setting InputNL to an nu-by-1 array of nonlinearity estimators. To specify the same nonlinearity for all inputs, specify a single input nonlinearity estimator.

Default: 'pwlinear'

OutputNonlinearity

Output nonlinearity estimator, specified as one of the following:

 'pwlinear' or pwlinear object (default) Piecewise linear function 'sigmoidnet' or sigmoidnet object Sigmoid network 'wavenet' or wavenet object Wavelet network 'saturation' or saturation object Saturation 'deadzone' or deadzone object Dead zone 'poly1d' or poly1d object One- dimensional polynomial 'unitgain' or [] or unitgain object Unit gain customnet object Custom network

Specifying a character vector creates a nonlinearity estimator object with default settings. Use object representation instead to configure the properties of a nonlinearity estimator.

OutputNonlinearity = sigmoidnet;
OutputNonlinearity.NumberOfUnits = 10;

Alternatively, use the associated input nonlinearity estimator function with Name-Value pair arguments.

OutputNonlinearity = sigmoidnet('NumberOfUnits',10);

For ny output channels, you can specify nonlinear estimators individually for each output channel by setting OutputNL to an ny-by-1 array of nonlinearity estimators. To specify the same nonlinearity for all outputs, specify a single output nonlinearity estimator.

Default: 'pwlinear'

LinearModel

The linear model in the linear block of the model structure, represented as an idpoly object. This property is read only.

Report

Summary report that contains information about the estimation options and results when the model is estimated using the nlhw command. Use Report to query a model for how it was estimated, including:

• Estimation method

• Estimation options

• Search termination conditions

• Estimation data fit

The contents of Report are irrelevant if the model was created by construction.

m = idnlhw([2 2 1]);
m.Report.OptionsUsed
ans =

[]

If you use nlhw to estimate the model, the fields of Report contain information on the estimation data, options, and results.

load iddata1;
m = nlhw(z1,[2 2 1],[],'pwlinear');
m.Report.OptionsUsed
Option set for the nlhw command:

InitialCondition: 'zero'
Display: 'off'
Regularization: [1x1 struct]
SearchMethod: 'auto'
SearchOption: [1x1 idoptions.search.identsolver]
OutputWeight: 'noise'
Advanced: [1x1 struct]

Report is a read-only property.

For more information on this property and how to use it, see Output Arguments in the nlhw reference page and Estimation Report.

TimeVariable

Independent variable for the inputs, outputs, and—when available—internal states, specified as a character vector.

Default: 't'

NoiseVariance

Noise variance (covariance matrix) of the model innovations e.
Assignable value is an ny-by-ny matrix.
Typically set automatically by the estimation algorithm.

Ts

Sample time. Ts is a positive scalar representing the sampling period. This value is expressed in the unit specified by the TimeUnit property of the model.

Changing this property does not discretize or resample the model.

Default: 1

TimeUnit

Units for the time variable, the sample time Ts, and any time delays in the model, specified as one of the following values:

• 'nanoseconds'

• 'microseconds'

• 'milliseconds'

• 'seconds'

• 'minutes'

• 'hours'

• 'days'

• 'weeks'

• 'months'

• 'years'

Changing this property has no effect on other properties, and therefore changes the overall system behavior. Use chgTimeUnit (Control System Toolbox) to convert between time units without modifying system behavior.

Default: 'seconds'

InputName

Input channel names, specified as one of the following:

• Character vector — For single-input models, for example, 'controls'.

• Cell array of character vectors — For multi-input models.

Alternatively, use automatic vector expansion to assign input names for multi-input models. For example, if sys is a two-input model, enter:

sys.InputName = 'controls';

The input names automatically expand to {'controls(1)';'controls(2)'}.

When you estimate a model using an iddata object, data, the software automatically sets InputName to data.InputName.

You can use the shorthand notation u to refer to the InputName property. For example, sys.u is equivalent to sys.InputName.

Input channel names have several uses, including:

• Identifying channels on model display and plots

• Extracting subsystems of MIMO systems

• Specifying connection points when interconnecting models

Default: '' for all input channels

InputUnit

Input channel units, specified as one of the following:

• Character vector — For single-input models, for example, 'seconds'.

• Cell array of character vectors — For multi-input models.

Use InputUnit to keep track of input signal units. InputUnit has no effect on system behavior.

Default: '' for all input channels

InputGroup

Input channel groups. The InputGroup property lets you assign the input channels of MIMO systems into groups and refer to each group by name. Specify input groups as a structure. In this structure, field names are the group names, and field values are the input channels belonging to each group. For example:

sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];

creates input groups named controls and noise that include input channels 1, 2 and 3, 5, respectively. You can then extract the subsystem from the controls inputs to all outputs using:

sys(:,'controls')

Default: Struct with no fields

OutputName

Output channel names, specified as one of the following:

• Character vector — For single-output models. For example, 'measurements'.

• Cell array of character vectors — For multi-output models.

Alternatively, use automatic vector expansion to assign output names for multi-output models. For example, if sys is a two-output model, enter:

sys.OutputName = 'measurements';

The output names automatically expand to {'measurements(1)';'measurements(2)'}.

When you estimate a model using an iddata object, data, the software automatically sets OutputName to data.OutputName.

You can use the shorthand notation y to refer to the OutputName property. For example, sys.y is equivalent to sys.OutputName.

Output channel names have several uses, including:

• Identifying channels on model display and plots

• Extracting subsystems of MIMO systems

• Specifying connection points when interconnecting models

Default: '' for all output channels

OutputUnit

Output channel units, specified as one of the following:

• Character vector — For single-output models. For example, 'seconds'.

• Cell array of character vectors — For multi-output models.

Use OutputUnit to keep track of output signal units. OutputUnit has no effect on system behavior.

Default: '' for all output channels

OutputGroup

Output channel groups. The OutputGroup property lets you assign the output channels of MIMO systems into groups and refer to each group by name. Specify output groups as a structure. In this structure, field names are the group names, and field values are the output channels belonging to each group. For example:

sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];

creates output groups named temperature and measurement that include output channels 1, and 3, 5, respectively. You can then extract the subsystem from all inputs to the measurement outputs using:

sys('measurement',:)

Default: Struct with no fields

Name

System name, specified as a character vector. For example, 'system_1'.

Default: ''

Notes

Any text that you want to associate with the system, stored as a string or a cell array of character vectors. The property stores whichever data type you provide. For instance, if sys1 and sys2 are dynamic system models, you can set their Notes properties as follows:

sys1.Notes = "sys1 has a string.";
sys2.Notes = 'sys2 has a character vector.';
sys1.Notes
sys2.Notes
ans =

"sys1 has a string."

ans =

'sys2 has a character vector.'

Default: [0×1 string]

UserData

Any type of data you want to associate with system, specified as any MATLAB® data type.

Default: []

## Output Arguments

collapse all

Hammerstein-Wiener model, returned as an idnlhw object. This model is created using the specified model orders and delays, input and output nonlinearity estimators, and properties.

## More About

collapse all

### Hammerstein-Wiener Model Structure

This block diagram represents the structure of a Hammerstein-Wiener model:

Where,

• f is a nonlinear function that transforms input data u(t) as w(t) = f(u(t)).

w(t), an internal variable, is the output of the Input Nonlinearity block and has the same dimension as u(t).

• B/F is a linear transfer function that transforms w(t) as x(t) = (B/F)w(t).

x(t), an internal variable, is the output of the Linear block and has the same dimension as y(t).

B and F are similar to polynomials in a linear Output-Error model. For more information about Output-Error models, see What Are Polynomial Models?.

For ny outputs and nu inputs, the linear block is a transfer function matrix containing entries:

$\frac{{B}_{j,i}\left(q\right)}{{F}_{j,i}\left(q\right)}$

where j = 1,2,...,ny and i = 1,2,...,nu.

• h is a nonlinear function that maps the output of the linear block x(t) to the system output y(t) as y(t) = h(x(t)).

Because f acts on the input port of the linear block, this function is called the input nonlinearity. Similarly, because h acts on the output port of the linear block, this function is called the output nonlinearity. If your system contains several inputs and outputs, you must define the functions f and h for each input and output signal. 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.

The software computes the Hammerstein-Wiener model output y in three stages:

1. Compute w(t) = f(u(t)) from the input data.

w(t) is an input to the linear transfer function B/F.

The input nonlinearity is a static (memoryless) function, where the value of the output a given time t depends only on the input value at time t.

You can configure the input nonlinearity as a sigmoid network, wavelet network, saturation, dead zone, piecewise linear function, one-dimensional polynomial, or a custom network. You can also remove the input nonlinearity.

2. Compute the output of the linear block using w(t) and initial conditions: x(t) = (B/F)w(t).

You can configure the linear block by specifying the orders of numerator B and denominator F.

3. Compute the model output by transforming the output of the linear block x(t) using the nonlinear function h as y(t) = h(x(t)).

Similar to the input nonlinearity, the output nonlinearity is a static function. You can configure the output nonlinearity in the same way as the input nonlinearity. You can also remove the output nonlinearity, such that y(t) = x(t).

Resulting models are idnlhw objects that store all model data, including model parameters and nonlinearity estimators. For more information about these objects, see Nonlinear Model Structures.

### Definition of idnlhw States

The states of a Hammerstein-Wiener model correspond to the states of the linear block in the model structure. The linear block contains all the dynamic elements of the model. If the linear block is not a state-space structure, the states are defined as those of model Mss, where Mss = idss(Model.LinearModel) and Model is the idnlhw object.

States are required for simulation, prediction, and linearization of Hammerstein-Wiener models. To specify the initial states:

## See Also

Introduced in R2007a

Get trial now