# pwlinear

Class representing piecewise-linear nonlinear estimator for Hammerstein-Wiener models

## Syntax

`t=pwlinear('NumberOfUnits',N)t=pwlinear('BreakPoints',BP)t=pwlinear(Property1,Value1,...PropertyN,ValueN)`

## Description

`pwlinear` is an object that stores the piecewise-linear nonlinear estimator for estimating Hammerstein-Wiener models.

You can use the constructor to create the nonlinearity object, as follows:

`t=pwlinear('NumberOfUnits',N)` creates a piecewise-linear nonlinearity estimator object with `N` breakpoints.

`t=pwlinear('BreakPoints',BP)` creates a piecewise-linear nonlinearity estimator object with breakpoints at values `BP`.

`t=pwlinear(Property1,Value1,...PropertyN,ValueN)` creates a piecewise-linear nonlinearity estimator object specified by properties in pwlinear Properties.

Use `evaluate(p,x)` to compute the value of the function defined by the `pwlinear` object `p` at `x`.

## pwlinear Properties

You can include property-value pairs in the constructor to specify the object.

After creating the object, you can use `get` or dot notation to access the object property values. For example:

```% List all property values get(p) % Get value of NumberOfUnits property p.NumberOfUnits```
Property NameDescription
`NumberOfUnits`

Integer specifies the number of breakpoints.
Default=`10`.

For example:

`pwlinear('NumberOfUnits',5)`
`BreakPoints`

2-by-`n` matrix containing the breakpoint `x` and `y` value, specified using the following format:

[x1,x2, ...., xn;y1, y2, ..., yn].

If set to a 1-by-`n` vector, the values are interpreted as `x`-values and the corresponding `y`-values are set to zero.

## Examples

Use `pwlinear` to specify the piecewise nonlinearity estimator in Hammerstein-Wiener models. For example:

`m=nlhw(Data,Orders,pwlinear('Br',[-1:0.1:1]),[]);`

The piecewise nonlinearity is initialized at the specified breakpoints. The breakpoint values are adjusted to the estimation data by `nlhw`.

expand all

### Tips

Use `pwlinear` to define a nonlinear function $y=F\left(x\right)$, where F is a piecewise-linear (affine) function of x and there are `n` breakpoints (xk,yk), k = 1,...,n. yk = F(xk). F is linearly interpolated between the breakpoints. y and x are scalars.

F is also linear to the left and right of the extreme breakpoints. The slope of these extension is a function of xi and yi breakpoints. The breakpoints are ordered by ascending `x`-values, which is important when you set a specific breakpoint to a different value.

There are minor deviations from the breakpoint values you set and the values actually stored in the object because the toolbox represent breakpoints differently internally.