| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → System Identification Toolbox |
| Contents | Index |
| Learn more about System Identification Toolbox |
If the output of a system depends nonlinearly on its inputs, it might be possible to decompose the input-output relationship into two or more interconnected elements. In this case, you can represent the dynamics by a linear transfer function and capture the nonlinearities using nonlinear functions of inputs and outputs of the linear system. The Hammerstein-Wiener model achieves this configuration as a series connection of static nonlinear blocks with a dynamic linear block.
Hammerstein-Wiener model applications span several areas, such as modeling electro-mechanical system and radio frequency components, audio and speech processing and predictive control of chemical processes. These models are popular because they have a convenient block representation, transparent relationship to linear systems, and are easier to implement than heavy-duty nonlinear models (such as neural networks and Volterra models).
You can use the Hammerstein-Wiener model as a black-box model structure because it provides a flexible parameterization for nonlinear models. For example, you might estimate a linear model and try to improve its quality by adding an input or output nonlinearity to this model.
You can also use a Hammerstein-Wiener model as a grey-box structure to capture physical knowledge about process characteristics. For example, the input nonlinearity might represent typical physical transformations in actuators and the output nonlinearity might describe common sensor characteristics.
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 Black-Box Polynomial Models?.
For ny outputs and nu inputs, the linear block is a transfer function matrix containing entries:
![]()
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 bock 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 nonlinearity for each input and output channel.
The Hammerstein-Wiener model computes the output y in three stages:
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.
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.
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. See the idnlhw reference page for more information.
System Identification Toolbox software provides several scalar nonlinearity estimators F(x) for Hammerstein-Wiener models. The nonlinearity estimators are available for both the input and output nonlinearities f and h, respectively. For more information about F(x), see Structure of Hammerstein-Wiener Models.
Each nonlinearity estimator corresponds to an object class in this toolbox. When you estimate Hammerstein-Wiener models in the GUI, System Identification Toolbox creates and configures objects based on these classes. You can also create and configure nonlinearity estimators at the command line. For a detailed description of each estimator, see the references page of the corresponding nonlinearity class.
| Nonlinearity | Class | Structure | Comments |
|---|---|---|---|
| Piecewise linear (default) | pwlinear | A piece-wise linear function parameterized by breakpoint locations. | By default, the number of breakpoints is 10. |
| One layer sigmoid network | sigmoidnet |
| Default number of units n is 10. |
| Wavelet network | wavenet |
where
| By default, the estimation algorithm determines the number of units nautomatically. |
| Saturation | saturation | Parameterize hard limits on the signal value as upper and lower saturation limits. | Use to model known saturation effects on signal amplitudes. |
| Dead zone | deadzone | Parameterize dead zones in signals as the duration of zero response. | Use to model known dead zones in signal amplitudes. |
| One- dimensional polynomial | poly1d | Single-variable polynomial of a degree that you specify. | By default, the polynomial degree is 1. |
| Unit gain | unitgain | Excludes the input or output nonlinearity from the model structure to achieve a Wiener or Hammerstein configuration, respectively. | Useful for configuring multi-input, multi-output (MIMO) models to exclude nonlinearities from specific input and output channels. |
| Custom network (user-defined) | customnet | Similar to sigmoid network but you specify
| (For advanced use) Uses the unit function that you specify. |
Estimate a Hammerstein-Wiener model with default configuration by specifying only model order and input delay:
nb—The number of zeros plus one.
nf—The number of poles.
nk—The delay from input to the output in terms of the number of samples.
nb is the order of the transfer function numerator (B polynomial), and nf is the order of the transfer function denominator (F polynomial). As you fit different Hammerstein-Wiener models to your data, you can configure the linear block structure by specifying a different order and delay. For MIMO systems with ny outputs and nu inputs, nb, nf, and nk are ny-by-nu matrices.
By default, the input and output nonlinearity estimators are both piecewise linear functions, parameterized by breakpoint locations (see the pwlinear reference page). You can configure the input and output nonlinearity estimators by:
Configuring the input and output nonlinearity properties.
Excluding the input or output nonlinear block.
See these topics for detailed steps to change the model structure:
Tutorial – Identifying Nonlinear Black-Box Models Using the GUI
How to Estimate Hammerstein-Wiener Models at the Command Line
Estimation of Hammerstein-Wiener models uses iterative search to minimize the simulation error between the model output and the measured output.
You can configure the estimation method using the Algorithm properties of the idnlhw class. The most common of these properties are:
MaxIter—Maximum number of iterations.
SearchMethod—Search method for minimization of prediction or simulation errors, such as Gauss-Newton and Levenburg-Marquardt line search, and Trust-region reflective Newton approach.
Tolerance—Condition for terminating iterative search when the expected improvement of the parameter values is less than a specified value.
Display—Shows progress of iterative minimization in the MATLAB Command Window.
By default, the initial states of the model are zero and not estimated. However, you can choose to estimate initial states during model estimation, which sometimes helps to achieve better results.
In the System Identification Tool GUI, select Estimate > Nonlinear models to open the Nonlinear Models dialog box.
In the Configure tab, select Hammerstein-Wiener from the Model type list.
(Optional) Edit the Model name by clicking the pencil icon. The name of the model should be unique to all Hammerstein-Wiener models in the System Identification Tool GUI.
(Optional) If you want to refine a previously estimated model, click Initialize to select a previously estimated model from the Initial Model list.
Note Refining a previously estimated model starts with the parameter values of the initial model and uses the same model structure. You can change these settings. |
The Initial Model list includes models that:
Exist in the System Identification Tool GUI.
Have the same number of inputs and outputs as the dimensions of the estimation data (selected as Working Data in the System Identification Tool GUI).
Keep the default settings in the Nonlinear Models dialog box that specify the model structure and the algorithm, or modify these settings:
Note For more information about available options, click Help in the Nonlinear Models dialog box to open the GUI help. |
| What to Configure | Options in Nonlinear Models GUI | Comment |
|---|---|---|
| Input or output nonlinearity | In the I/O Nonlinearity tab, select the Nonlinearity and specify the No. of Units. | If you do not know which nonlinearity to try, use the (default) piecewise linear nonlinearity. When you estimate from binary input data, you cannot reliably estimate the input nonlinearity. In this case, set Nonlinearity for the input channel to None. For multiple-input and multiple-output systems, you can assign nonlinearities to specific input and output channels. |
| Model order and delay | In the Linear Block tab, specify B Order, F Order, and Input Delay. For MIMO systems, select the output channel and specify the orders and delays from each input channel. | If you do not know the input delay values, click Infer Input Delay. This action opens the Infer Input Delay dialog box which suggests possible delay values. |
| Estimation algorithm | In the Estimate tab, click Algorithm Options. | You can specify to estimate initial states. |
Click Estimate to add this model to the System Identification Tool GUI.
The Estimate tab displays the estimation progress and results.
Validate the model response by selecting the desired plot in the Model Views area of the System Identification Tool GUI. For more information about validating models, see Model Analysis.
If you get a poor fit, try changing the model structure or algorithm configuration in step 5.
You can export the model to the MATLAB workspace by dragging it to To Workspace in the System Identification Tool GUI.
Configure the nonlinearity estimator.
Exclude the input or output nonlinearity.
Improving estimation results using initial states.
What if you cannot get a satisfactory model?
Use nlhw to estimate a Hammerstein-Wiener model for the data in Tutorial – Identifying Nonlinear Black-Box Models Using the GUI.
Prepare the data for estimation:
load twotankdata z = iddata(y, u, 0.2); ze = z(1:1000); zv = z(1001:3000);
Estimate several models using different model orders, delays, and nonlinearity settings:
m1 = nlhw(ze,[2 3 1]);
m2 = nlhw(ze,[2 2 3]);
m3 = nlhw(ze,[2 2 3], pwlinear('num',13),...
pwlinear('num',10));
m4 = nlhw(ze,[2 2 3], sigmoidnet('num',2),...
pwlinear('num',10));
An alternative way to perform the estimation is to configure the model structure first, and then to estimate this model:
m5 = idnlhw([2 2 3], 'dead','sat') m5 = pem(ze,m5)
Compare the resulting models by plotting the model outputs on top of the measured output:
compare(zv,m1,m2,m3,m4,m5)

Use the Hammerstein-Wiener model structure to improve a previously estimated linear model. After estimating the linear model, insert it into the Hammerstein-Wiener structure that includes input or output nonlinearities.
Estimate a linear model:
load iddata1 LM = arx(z1,[2 2 1]);
Extract the transfer function coefficients from the linear model:
[Num, Den] = tfdata(LM);
Create a Hammerstein-Wiener model, where you initialize the linear block properties B and F using Num and Den, respectively:
nb = 1; % In general, nb = ones(ny,nu)
% ny is number of outputs
% nu is number of inputs
nf = nb;
nk = 0; % In general, nk = zeros(ny,nu)
% ny is number of outputs
% nu is number of inputs
M = idnlhw([nb nf nk],'poly1d','pwlinear');
M.b = Num;
M.f = Den;
Estimate the model coefficients, which refines the linear model coefficients in Num and Den:
M = pem(z1, M);
Compare responses of linear and nonlinear model against measured data:
compare(z1,LM,M)
Simulation and Code Generation Using Simulink
In most applications, sim(idnlhw) and predict(idnlhw) are sufficient for computing the simulated and predicted model response, respectively. This advanced topic describes how the software evaluates the output of nonlinearity estimators and uses this output to compute the model response.
Evaluating the predicted output of a nonlinearity for a input u requires that you first extract the input or output nonlinearity F from the model:
F = M.InputNonlinearity % equivalent to F = M.unl H = M.OutputNonlinearity % equivalent to F = M.ynl
Evaluate F(u):
w = evaluate(F,u)
where u is a scalar representing the value of the input signal at a given time.
You can evaluate predicted output values at multiple time instants by evaluating F for several time values simultaneously using a column vector of input values:
w = evaluate(F,[u1;u2;u3])
Similarly, you can evaluate the value of the nonlinearity H using the output of the linear block x(t) as its input:
y = evaluate(H,x)
For MIMO models, F and H are vectors of length nu and ny, respectively. nu is the number of inputs and ny is the number of outputs. In this case, you must evaluate the predicted output of each nonlinearity separately.
For example, suppose that you estimate a two-input model:
M = nlhw(data,[nb nf nk],[wavenet;poly1d],'saturation')
In the input nonlinearity:
F = M.InputNonlinearity F1 = F(1); F2 = F(2);
F is a vector function containing two elements: F=[F1(u1_value); F2(u2_value)], where F1 is a wavenet object and F2 is a poly1d object. u1_value is the first input signal and u2_value is the second input signal.
Evaluate F by evaluating F1 and F2 separately:
w1 = evaluate(F(1), u1_value); w2 = evaluate(F(2), u2_value);
The total input to the linear block, w, is a vector of w1 and w2 (w = [w1 w2]).
Similarly, you can evaluate the value of the nonlinearity H:
H = M.OutputNonlinearity %equivalent to H = M.ynl
This example shows how the software evaluates the simulated output by first computing the output of the input and output nonlinearity estimators. For same initial conditions, the prediction results match the simulation results.
Estimate Hammerstein-Wiener model:
load twotankdata estData = iddata(y,u,0.2) M = nlhw(estData,[1 5 3],'pwlinear','poly1d');
Extract the input nonlinearity, linear model, and output nonlinearity as separate variables:
uNL = M.InputNonlinearity; linModel = M.LinearModel; yNL = M.OutputNonlinearity;
Simulate the output of the input nonlinearity estimator:
u = estData.u; %input data for simulation % Compute output of input nonlinearity: w = evaluate(uNL, u); % Response of linear model to input w and zero % initial conditions: x = sim(linModel, w); % Compute the output of the Hammerstein-Wiener model M % as the output of the output nonlinearity estimator to input x: y = evaluate(yNL, x); % Previous commands are equivalent to: ysim = sim(M, u); % Compare low-level and direct simulation results: time = estData.SamplingInstants; plot(time, y, time, ysim, '.')
![]() | Identifying Nonlinear ARX Models | Linear Approximation of Nonlinear Black-Box Models | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |