Main Content

polyreg

(Not recommended) Powers and products of standard regressors

polyreg is not recommended. Use polynomialRegressor instead to create polynomial regressor objects, and them add them directly to the regressor idnlarx Regressors property. For more information, see Compatibility Considerations.

Syntax

R = polyreg(model)
R = polyreg(model,'MaxPower',n)
R = polyreg(model,'MaxPower',n,'CrossTerm',CrossTermVal)

Description

R = polyreg(model) creates an array R of polynomial regressors up to the power 2. If a model order has input u and output y, na=nb=2, and delay nk=1, polynomial regressors are y(t−1)2, u(t−1)2, y(t−2)2, u(t−2)2. model is an idnlarx object. You must add these regressors to the model by assigning the CustomRegressors model property or by using addreg.

R = polyreg(model,'MaxPower',n) creates an array R of polynomial regressors up to the power n. Excludes terms of power 1 and cross terms, such as y(t−1)*u(t−1).

R = polyreg(model,'MaxPower',n,'CrossTerm',CrossTermVal) creates an array R of polynomial regressors up to the power n and includes cross terms (products of standards regressors) when CrossTermVal is 'on'. By default, CrossTermVal is 'off'.

Examples

collapse all

Estimate a nonlinear ARX model with na=2, nb=2, and nk=1, and nonlinearity estimator wavenet.

load iddata1
m = nlarx(z1,[2 2 1]);

Create polynomial regressors.

R = polyreg(m);

Estimate the model.

m = nlarx(z1,[2 2 1],idWaveletNetwork,'CustomReg',R);

View all model regressors (standard and custom).

getreg(m)
ans = 8x1 cell
    {'y1(t-1)'   }
    {'y1(t-2)'   }
    {'u1(t-1)'   }
    {'u1(t-2)'   }
    {'y1(t-1).^2'}
    {'y1(t-2).^2'}
    {'u1(t-1).^2'}
    {'u1(t-2).^2'}

Estimate a nonlinear ARX model with na=2, nb=1, and nk=1, and nonlinearity estimator wavenet.

load iddata1
m = nlarx(z1,[2 1 1]);

Create polynomial regressors.

R = polyreg(m,'MaxPower',3,'CrossTerm','on')
16x1 array of Custom Regressors with fields: Function, Arguments, Delays, Vectorized

If the model m has three standard regressors a, b and c, then R includes the terms a2, b2, c2, ab, ac, bc, a2b, a2c, ab2, abc, ac2, b2c, bc2, a3, b3, and c3.

Estimate the model.

m = nlarx(z1,[2 1 1],idWaveletNetwork,'CustomReg',R);

Version History

Introduced in R2007a

collapse all

R2021a: polyreg is not recommended

Starting in R2021a, the polyreg command is not recommended. Use the polynomialRegressor command instead to construct polynomial regressors. Doing so improves the computation speed and the accuracy of results, reduces the memory footprint of the idnlarx object, and improves code generation in Simulink®.

After creating a polynomial regressor, add it directly to the idnlarx model Regressor property by using the syntax model.Regressors(end+1) = new_polymomial_regressor_object.

There are no plans to remove polyreg at this time.