Main Content

idPiecewiseConstant

Piecewise-constant nonlinearity estimator object

Since R2025a

Description

The idPiecewiseConstant object stores the piecewise-constant nonlinearity estimator for estimating Hammerstein-Wiener models. You can use piecewise constant nonlinearity in Hammerstein-Wiener models to model hysteretic behavior, quantization nonlinearity, and gain-scheduled linear models.

Use idPiecewiseConstant to define a nonlinear function y=F(x), where y and x are scalars. The nonlinearity function, F, is a piecewise constant function of x. There are n break points (xk,yk), k = 1,...,n, such that yk = F(xk). F is calculated at each break point and remains constant until the next break point. F is also constant to the left and right of the extreme break points.

The break points are ordered by ascending x values, which is important to consider when you want to set a specific break point to a different value. There are minor differences between the break point values you set and the values stored in the object because the toolbox has a different internal representation of break points.

For example, in this plot, the break points are xk = [-2,1,4] and the corresponding nonlinearity values are yk = [4,3,5].

You compute the value of F(x) using evaluate(NL,x), where NL is the idPiecewiseConstant object. When using evaluate, you have to initialize the break points manually. Use the stairs command to obtain the plot.

For idPiecewiseConstant object properties, see Properties.

Creation

Description

NL = idPiecewiseConstant creates a default piecewise-constant nonlinearity estimator object with 10 break points for estimating Hammerstein-Wiener models. The break points and their nonlinearities are set to []. The initial values of the nonlinearities are determined from the estimation data range during estimation using nlhw.

example

NL = idPiecewiseConstant(numberOfUnits) creates a piecewise-constant nonlinearity estimator object for estimating Hammerstein-Wiener models with the number of break points equal to numberOfUnits. The break points and their nonlinearities are set to [].

NL = idPiecewiseConstant(BreakPoints=breakPoints) creates a piecewise-constant nonlinearity estimator object with the break points and their corresponding nonlinearity values as specified in breakPoints.

example

Input Arguments

expand all

Number of break points, specified as a positive integer.

This argument sets the NumberOfUnits property.

Break points, xk, and the corresponding nonlinearity values at the break points, yk, specified as one of these values:

  • 2-by-n matrix — The x and y values for each of the n break points are specified as [x1,x2,...,xn;y1,y2,...,yn].

  • 1-by-n vector — The specified vector is interpreted as the x values of the break points: x1,x2,...,xn. All the y values of the break points are set to match the corresponding x values, that is, y1 = x1, y2 = x2, and so on.

By default, the break points and their nonlinearities are set to [].

This argument sets the BreakPoints property. If the BreakPoints property is not [], the NumberOfUnits property is automatically set to the number of columns in BreakPoints, n.

When you create the nonlinearity object, the software sorts the break points by ascending x values. This sorting is important to consider if you want to set a specific break point to a different value after creating the object.

Properties

expand all

idPiecewiseConstant object properties include:

Number of break points, specified as a positive integer.

Break points, xk, and the corresponding nonlinearity values at the break points, yk, specified as one of these values:

  • 2-by-n matrix — The x and y values for each of the n break points are specified as [x1,x2,...,xn;y1,y2,...,yn].

  • 1-by-n vector — The specified vector is interpreted as the x values of the break points: x1,x2,...,xn. All the y values of the break points are set to match the corresponding x values, that is, y1 = x1, y2 = x2, and so on.

By default, the break points and their nonlinearities are set to [].

If the BreakPoints property is not [], the NumberOfUnits property is automatically set to the number of columns in BreakPoints, n.

When you create the nonlinearity object, the software sorts the break points by ascending x values. This sorting is important to consider if you want to set a specific break point to a different value after creating the object.

Option to fix or free the values in the mapping object, specified as a logical scalar. When you set Free to false, the object does not update during estimation.

Object Functions

idnlhwHammerstein-Wiener Model
nlhwEstimate Hammerstein-Wiener model

Examples

collapse all

Create a default piecewise-constant nonlinearity estimator object using idPiecewiseConstant.

NL = idPiecewiseConstant
NL = 
Piecewise Constant
    NumberOfUnits: 10
      BreakPoints: []
             Free: 1

By default, the NL object has 10 break points. Change the number of break points to 5 by specifying the NumberOfUnits property.

NL.NumberOfUnits = 5
NL = 
Piecewise Constant
    NumberOfUnits: 5
      BreakPoints: []
             Free: 1

Load estimation data.

load twotankdata;
z = iddata(y,u,0.2,'Name','Two tank system');
z1 = z(1:1000);

Create an idPiecewiseConstant object and specify the breakpoints.

InputNL = idPiecewiseConstant(BreakPoints=[-2,1,4])
InputNL = 
Piecewise Constant
Inputs: u(t)
Output: y(t)
    NumberOfUnits: 3
      BreakPoints: [2×3 double]
             Free: 1

Because the BreakPoints property is specified as a vector, the specified vector is interpreted as the x values of the break points. The y values of the break points are set to be equal to the corresponding x values and are determined during model estimation.

Estimate model with no output nonlinearity using nlhw.

sys = nlhw(z1,[2 3 0],InputNL,[]);

Version History

Introduced in R2025a