- https://www.mathworks.com/help/ident/ref/selstruc.html - Documentation for ‘selstruc’ function.
- https://www.mathworks.com/help/ident/ref/nlarx.html - Documentation for ‘nlarx’ function

# To understand more on the nlarx tutorial

4 views (last 30 days)

Show older comments

Hi all,

When I am studying the tutorial of the function nlarx: https://nl.mathworks.com/help/ident/ug/two-tank-system-single-input-single-output-nonlinear-arx-and-hammerstein-wiener-models.html

There is a statement "The AIC criterion has selected nn = [na nb nk] = [5 1 3], meaning that, in the selected ARX model structure, y(t) is predicted by the 6 regressors y(t-1),y(t-1),...,y(t-5) and u(t-3). We will try to use these values when estimating nonlinear models."

May I know why there would be two times "y(t-1)" in the regressor set?

This may be a silly question but I would appreciate if anyone could help out. Thanks a lot in advance!

##### 0 Comments

### Accepted Answer

Garmit Pant
on 6 Nov 2023

Hello KW YAN

I understand that you are trying to understand the use of the function ‘nlarx’ and following an example given in the MATLAB Documentation.

In the tutorial that you are following, the function ‘selstruc’ is used to identify the model structure and the set of linear regressors. The variable ‘nn’ contains the order matrix of the form [na nb nk] denoting the numbers of past outputs, past inputs and the input delay used in the regressor formulas.

Thus, nn = [5 1 3] implies that the output variable uses lags (1,2,3,4,5) and the input variable uses the only one lag (3) leading to the regressor set {y(t-1), y(t-2), y(t-3), y(t-4), y(t-5),u(t-3)}. This is inconsistent with regressor set mentioned in the example, i.e. { y(t-1), y(t-1), y(t-3), y(t-4), y(t-5),u(t-3)}. This seems to be an error in the example since the regressor set should include {y(t-1),y(t-2)…} and not {y(t-1),y(t-1)…}.

This can also be confirmed by checking ‘mw1.Regressors.Lags’ after creating an ‘nlarx’ object using the order matrix [5 1 3]. ‘mw1.Regressors.Lags’ has the arrays [1,2,3,4,5] and [3] stored which validates that the regressor set is {y(t-1), y(t-2), y(t-3), y(t-4), y(t-5),u(t-3)}. Refer to the following code snippet to run and validate this.

load twotankdata

z = iddata(y, u, 0.2, 'Name', 'Two tank system');

z1 = z(1:1000);

z2 = z(1001:2000);

z3 = z(2001:3000);

plot(z1,z2,z3)

legend('Estimation','Validation 1', 'Validation 2')

mw1 = nlarx(z1,[5 1 3]);

disp(mw1.Regressors.Lags)

For further understanding, you can refer to the following MATLAB Documentation:

I hope this helps!

Best Regards

Garmit

### More Answers (0)

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!