Documentation

addreg

Add custom regressors to nonlinear ARX model

Syntax

m = addreg(model,regressors)
m = addreg(model,regressors,output)

Description

m = addreg(model,regressors) adds custom regressors to a nonlinear ARX model by appending the CustomRegressors model property. model and m are idnalrx objects. For single-output models, regressors is an object array of regressors you create using customreg or polyreg, or a cell array of string expressions. For multiple-output models, regressors is 1-by-ny cell array of customreg objects or 1-by-ny cell array of cell arrays of string expressions. addreg adds each element of the ny cells to the corresponding model output channel. If regressors is a single regressor, addreg adds this regressor to all output channels.

m = addreg(model,regressors,output) adds regressors regressors to specific output channels output of a multiple-output model. output is a scalar integer or vector of integers, where each integer is the index of a model output channel. Specify several pairs of regressors and output values to add different regressor variables to the corresponding output channels.

Examples

collapse all

Add Regressors to a Nonlinear ARX Model as a Cell Array of Strings

Create nonlinear ARX model with standard regressors.

  m1 = idnlarx([4 2 1],'wavenet','nlr',[1:3]);

Create model with additional custom regressors.

  m2 = addreg(m1,{'y1(t-2)^2';'u1(t)*y1(t-7)'});

List all standard and custom regressors of m2.

  getreg(m2)
Regressors:
    y1(t-1)
    y1(t-2)
    y1(t-3)
    y1(t-4)
    u1(t-1)
    u1(t-2)
    y1(t-2)^2
    u1(t)*y1(t-7)

Add Regressors to a Nonlinear ARX Model as customreg Objects

Create nonlinear ARX model with standard regressors.

m1 = idnlarx([4 2 1],'wavenet','nlr',[1:3]);

Create customreg objects.

r1 = customreg(@(x)x^2,{'y1'},2)
Custom Regressor: 
String expression: y1(t-2)^2
        Function: @(x)x^2
       Arguments: {'y1'}
          Delays: 2
      Vectorized: 0
    TimeVariable: 't'

r2 = customreg(@(x,y)x*y,{'u1','y1'},[0 7])
Custom Regressor: 
String expression: u1(t)*y1(t-7)
        Function: @(x,y)x*y
       Arguments: {'u1'  'y1'}
          Delays: [0 7]
      Vectorized: 0
    TimeVariable: 't'

Create a model based on m1 with custom regressors.

m2 = addreg(m1,[r1 r2]);

List all standard and custom regressors of m2.

getreg(m2)
Regressors:
    y1(t-1)
    y1(t-2)
    y1(t-3)
    y1(t-4)
    u1(t-1)
    u1(t-2)
    y1(t-2)^2
    u1(t)*y1(t-7)

See Also

| | |

Introduced in R2007a

Was this topic helpful?