Main Content

addreg

(Not recommended) Add custom regressors to nonlinear ARX model

addreg is not recommended. Add linear, polynomial, and custom regressors directly to the idnlarx Regressors property instead. For more information, see Compatibility Considerations.

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 character vectors. For multiple-output models, regressors is 1-by-ny cell array of customreg objects or 1-by-ny cell array of cell arrays of character vectors. 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

Create nonlinear ARX model with standard regressors.

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

Create model with additional custom regressors, specified as a cell array of character vectors.

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

List all standard and custom regressors of m2.

  getreg(m2)
ans = 8x1 cell
    {'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)'}

Create nonlinear ARX model with standard regressors.

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

Create customreg objects.

r1 = customreg(@(x)x^2,{'y1'},2)
Custom Regressor:
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:
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)
ans = 8x1 cell
    {'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)'}

Version History

Introduced in R2007a

collapse all

R2021a: addreg is not recommended

Starting in R2021a, add regressor objects linearRegressor, polynomialRegressor, and customRegressor directly to the idnlarx model Regressor property by using the syntax model.Regressors(end+1) = new_regressor_object. There are no plans to remove addreg at this time.