Documentation

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 Hammerstein-Wiener Model Structure with Default Nonlinearities

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.

Create Hammerstein-Wiener Model with Specific Input-Output Nonlinearities

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.

Create Hammerstein-Wiener Model and Configure the Nonlinearities

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

Create a Wiener Model and Estimate Model Parameters

Create a Wiener model (no input nonlinearity).

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

Estimate the model.

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

Create Hammerstein-Wiener Model Using Input-Output Polynomial Model of Output-Error Structure

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');

Related Examples

Input Arguments

collapse all

Orders — Order and delays of the linear subsystem transfer function [nb nf nk] vector of positive integers | [nb nf nk] vector of matrices

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.

InputNL — Input static nonlinearitystring | nonlinearity estimator object | array of nonlinearity estimator objects or strings

Input static nonlinearity estimator, specified as a nonlinearity estimator object or string representing the nonlinearity estimator type.

'pwlinear' or pwlinear object
(default)
Piecewise linear function
'sigmoidnet' or sigmoidnet objectSigmoid network
'wavenet' or wavenet objectWavelet network
'saturation' or saturation objectSaturation
'deadzone' or deadzone objectDead zone
'poly1d' or poly1d objectOne-
dimensional polynomial
'unitgain' or [] or unitgain objectUnit gain
customnet objectCustom network

Specifying a string 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.

OutputNL — Output static nonlinearitystring | nonlinearity estimator object | array of nonlinearity estimator objects

Output static nonlinearity estimator, specified as a nonlinearity estimator object or string representing the nonlinearity estimator type.

'pwlinear' or pwlinear object
(default)
Piecewise linear function
'sigmoidnet' or sigmoidnet objectSigmoid network
'wavenet' or wavenet objectWavelet network
'saturation' or saturation objectSaturation
'deadzone' or deadzone objectDead zone
'poly1d' or poly1d objectOne-
dimensional polynomial
'unitgain' or [] or unitgain objectUnit gain
customnet objectCustom network

Specifying a string 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.

LinModel — Discrete time linear modelidpoly | idss with K = 0 | idtf

Discrete-time linear model used to specify the linear subsytem, 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 single 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 a nonlinearity estimator object or string representing the nonlinearity estimator type.

'pwlinear' or pwlinear object
(default)
Piecewise linear function
'sigmoidnet' or sigmoidnet objectSigmoid network
'wavenet' or wavenet objectWavelet network
'saturation' or saturation objectSaturation
'deadzone' or deadzone objectDead zone
'poly1d' or poly1d objectOne-
dimensional polynomial
'unitgain' or [] or unitgain objectUnit gain
customnet objectCustom network

Specifying a string 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 a nonlinearity estimator object or string representing the nonlinearity estimator type.

'pwlinear' or pwlinear object
(default)
Piecewise linear function
'sigmoidnet' or sigmoidnet objectSigmoid network
'wavenet' or wavenet objectWavelet network
'saturation' or saturation objectSaturation
'deadzone' or deadzone objectDead zone
'poly1d' or poly1d objectOne-
dimensional polynomial
'unitgain' or [] or unitgain objectUnit gain
customnet objectCustom network

Specifying a string 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
          Status: 'Created by direct construction or transformation. Not estimated.'
         Method: ''
            Fit: [1x1 struct]
     Parameters: [1x1 struct]
    OptionsUsed: []
      RandState: []
       DataUsed: [1x1 struct]
    Termination: [1x1 struct]
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
Status: 'Estimated using NLHW'
         Method: 'NLHW'
            Fit: [1x1 struct]
     Parameters: [1x1 struct]
    OptionsUsed: [1x1 idoptions.nlhw]
      RandState: []
       DataUsed: [1x1 struct]
    Termination: [1x1 struct]
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 string.

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

String representing the unit of the time variable. This property specifies the units for the time variable, the sample time Ts, and any time delays in the model. Use any 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 to convert between time units without modifying system behavior.

Default: 'seconds'

InputName

Input channel names. Set InputName to a string for single-input model. For a multi-input model, set InputName to a cell array of strings.

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: Empty string '' for all input channels

InputUnit

Input channel units. Use InputUnit to keep track of input signal units. For a single-input model, set InputUnit to a string. For a multi-input model, set InputUnit to a cell array of strings. InputUnit has no effect on system behavior.

Default: Empty string '' 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. Set OutputName to a string for single-output model. For a multi-output model, set OutputName to a cell array of strings.

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: Empty string '' for all output channels

OutputUnit

Output channel units. Use OutputUnit to keep track of output signal units. For a single-output model, set OutputUnit to a string. For a multi-output model, set OutputUnit to a cell array of strings. OutputUnit has no effect on system behavior.

Default: Empty string '' 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. Set Name to a string to label the system.

Default: ''

Notes

Any text that you want to associate with the system. Set Notes to a string or a cell array of strings.

Default: {}

UserData

Any type of data you wish to associate with system. Set UserData to any MATLAB® data type.

Default: []

Output Arguments

collapse all

sys — Hammerstein-Wiener modelidnlhw object

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:

  • w(t) = f(u(t)) is a nonlinear function transforming input data u(t). w(t) has the same dimension as u(t).

  • x(t) = (B/F)w(t) is a linear transfer function. x(t) has the same dimension as y(t).

    where B and F are similar to polynomials in the linear Output-Error model, as described in What Are Polynomial Models?.

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

    Bj,i(q)Fj,i(q)

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

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

w(t) and x(t) are internal variables that define the input and output of the linear block, respectively.

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 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 nonlinearities f and h are scalar functions, one nonlinear function for each input and output channel.

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

  1. Computes 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. Computes 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 numerator B and denominator F orders.

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

    Similar to the input nonlinearity, the output nonlinearity is a static function. 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 estimator.

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:

Was this topic helpful?