Documentation Center

  • Trial Software
  • Product Updates

nlarx

Estimate nonlinear ARX model

Syntax

m = nlarx(data,[na nb nk])
m = nlarx(data,[na nb nk],Nonlinearity)
m = nlarx(data,[na nb nk],'Name',Value)
m = nlarx(data,LinModel)
m = nlarx(data,LinModel,Nonlinearity)
m = nlarx(data,LinModel,Nonlinearity,'PropertyName',PropertyValue)

Description

m = nlarx(data,[na nb nk]) creates and estimates a nonlinear ARX model using a default wavelet network as its nonlinearity estimator. data is an iddata object. na, nb, and nk are positive integers that specify the model orders and delays.

m = nlarx(data,[na nb nk],Nonlinearity) specifies a nonlinearity estimator Nonlinearity, as a nonlinearity estimator object or string representing the nonlinearity estimator type.

m = nlarx(data,[na nb nk],'Name',Value) constructs and estimates the model using options specified as idnlarx model property or idnlarx algorithm property name and value pairs. Specify Name inside single quotes.

m = nlarx(data,LinModel) creates and estimates a nonlinear ARX model using a linear model (in place of [na nb nk]), and a wavelet network as its nonlinearity estimator. LinModel is a discrete time input-output polynomial model of ARX structure (idpoly). LinModel sets the model orders, input delay, input-output channel names and units, sample time, and time unit of m, and the polynomials initialize the linear function of the nonlinearity estimator.

m = nlarx(data,LinModel,Nonlinearity) specifies a nonlinearity estimator Nonlinearity.

m = nlarx(data,LinModel,Nonlinearity,'PropertyName',PropertyValue), constructs and estimates the model using options specified as idnlarx property name and value pairs.

Input Arguments

data

Time-domain iddata object.

na nb nk

Positive integers that specify the model orders and delays.

For ny output channels and nu input channels, na is an ny-by-ny matrix whose i-jth entry gives the number of delayed jth outputs used to compute the ith output. nb and nk are ny-by-nu matrices, where each row defines the orders for the corresponding output.

Nonlinearity

Nonlinearity estimator, specified as a nonlinearity estimator object or string representing the nonlinearity estimator type.

'wavenet' or wavenet object
(default)
Wavelet network
'sigmoidnet' or sigmoidnet objectSigmoid network
'treepartition' or treepartition objectBinary-tree
'linear' or [] or linear objectLinear function
neuralnet objectNeural network
customnet objectCustom network

Specifying a string creates a nonlinearity estimator object with default settings. Use object representation to configure the properties of a nonlinearity estimator.

For ny output channels, you can specify nonlinear estimators individually for each output channel by setting Nonlinearity to an ny-by-1 cell array or object array of nonlinearity estimators. To specify the same nonlinearity for all outputs, specify Nonlinearity as a single nonlinearity estimator.

LinModel

Discrete time input-output polynomial model of ARX structure (idpoly), typically estimated using the arx command.

Examples

Estimate nonlinear ARX model with default settings:

load twotankdata
Ts = 0.2; % Sampling interval is 0.2 min
z = iddata(y,u,Ts);  % constructs iddata object
m = nlarx(z,[4 4 1]) % na=nb=4 and nk=1
 

Estimate nonlinear ARX model with a specific nonlinearity:

  NL =  wavenet('NumberOfUnits',5);
% Wavelet network has 5 units
  m = nlarx(z,[4 4 1],NL)
 

Estimate nonlinear ARX model with a custom network nonlinearity:

% Define custom unit function and save it as gaussunit.m.
function [f, g, a] = GAUSSUNIT(x)
[f, g, a] = gaussunit(x)
f =  exp(-x.*x);
if nargout>1
  g = - 2*x.*f;
  a = 0.2;
end

% Estimate nonlinear ARX model using the custom
% Gauss unit function.
H = @gaussunit;
CNetw = customnet(H);
m = nlarx(data,[na nb nk],CNetw)
 

Estimate nonlinear ARX model with specific algorithm settings:

  m = nlarx(z,[4 4 1],'sigmoidnet','MaxIter',50,...
                      'Focus','Simulation')
% Maximum number of estimation iterations is 50.
% Estimation focus 'simulation' optimizes model for
% simulation applications.
 

Estimate nonlinear ARX model from time series data:

t = 0:0.01:10; 
y = 10*sin(2*pi*10*t)+rand(size(t)); 
z = iddata(y',[],0.01);
m = nlarx(z,2,'sigmoid')
compare(z,m,1) % compare 1-step-ahead
               % prediction of response
 

Estimate nonlinear ARX model and avoid local minima:

% Estimate initial model. 
  load iddata1
  m1=nlarx(z1,[4 2 1],'wave','nlr',[1:3])
% Perturb parameters slightly to avoid local minima:
  m2=init(m1)
% Estimate model with perturbed initial parameter values:
  m2=nlarx(z1,m2)
 

Estimate nonlinear ARX model with custom regressors:

% Load sample data z1 (iddata object).
  load iddata1
% Estimate the model parameters:
  m = nlarx(z1,[0 0 0],'linear','CustomReg',...
                                {'y1(t-1)^2',...
                                'y1(t-2)*u1(t-3)'})
% na=nb=nk=0 means there are no standard regressors.
% 'linear' means that the nonlinear estimator has only
% the linear function.
 

Estimate nonlinear ARX model with custom regressor object:

% Load sample data z1 (iddata object):
  load iddata1
% Define custom regressors as customreg objects:
  C1 = customreg(@(x)x^2,{'y1'}, [1]);	% y1(t-1)^2
  C2 = customreg(@(x,y)x*y,{'y1', 'u1'},...
                           [2 3]); % y1(t-2)*u1(t-3)
  C = [C1, C2]; % object array of custom regressors
% Estimate model with custom regressors:  
  m = nlarx(z1,[0 0 0],'linear','CustomReg',C);
% List all model regressors:
getreg(m) 
 

Estimate nonlinear ARX model and search for optimum regressors for input to the nonlinear function:

load iddata1
m = nlarx(z1,[4 4 1],'sigmoidnet',...
          'NonlinearRegressors','search');
m.NonlinearRegressors
% regressors indices in nonlinear function
 

Estimate nonlinear ARX model with selected regressors as inputs to the nonlinear function:

  load iddata1
  m = nlarx(z1,[4 4 1],'sigmoidnet',...
                       'NonlinearReg','input');
% Only input regressors enter the nonlinear function.
% m is linear in past outputs.
 

Estimate nonlinear ARX model with no linear term in the nonlinearity estimator:

  load iddata1
  SNL = sigmoidnet('LinearTerm','off')
  m = nlarx(z1,[2 2 1],SNL);
 

Estimate regularized nonlinear ARX model using a large number of units.

load regularizationExampleData.mat nldata
Orders = [1 2 1];
NL = sigmoidnet('NumberOfUnits',30);
% unregularized estimate
sys = nlarx(nldata, Orders, NL);
% regularized estimate using Lambda = 1e-8;
al = sys.Algorithm;
al.Regularization.Lambda = 1e-8;
sysr = nlarx(nldata, Orders, NL, 'Algorithm',al);
compare(nldata, sys, sysr);
 

Estimate MIMO nonlinear ARX model that has the same nonlinearity estimator for all output channels:

  m = nlarx(data,[[2 1;0 1] [2;1] [1;1]],...
                 sigmoidnet('num',7))
% m uses a sigmoid network with 7 units 
% for all output channels.
 

Estimate MIMO nonlinear ARX model with different nonlinearity estimator for each output channel:

  m = nlarx(data,[[2 1;0 1] [2;1] [1;1]],...
                 ['wavenet'; sigmoidnet('num',7)])
% first output channel uses a wavelet network
% second output channel uses a sigmoid network with 7 units
 

Estimate a nonlinear ARX model using an ARX model:

% Estimate  linear ARX model.
load throttledata.mat
Tr = getTrend(ThrottleData); 
Tr.OutputOffset = 15;
DetrendedData = detrend(ThrottleData, Tr);
LinearModel = arx(DetrendedData, [2 1 1], 'Focus', 'Simulation');

% Estimate nonlinear ARX model using linear model to model
% output saturation in data.
NonlinearModel = nlarx(ThrottleData, LinearModel, 'sigmoidnet',...
 'Focus', 'Simulation') 

See Also

| | | | |

Tutorials

Was this topic helpful?