How to use a matrix as input for NLARX

3 ビュー (過去 30 日間)
Leon
Leon 2023 年 4 月 3 日
コメント済み: Rajiv Singh 2023 年 4 月 10 日
Based on the text (see below in italic) for NLARX I would like to use a matrix to provide the u en y (input/output).
Comma-Separated Matrix Pair
Specify data as a comma-separated pair of real-valued matrices that contain input and output time-domain signal values. When you specify matrix-based data, the software assumes a sample time of 1 second. You can change the sample time after estimation by setting the property sys.Ts.
  • For SISO systems, specify data as a pair of Ns-element numeric column vectors that contain uniformly sampled input and output time-domain signal values. Here, Ns is the number of samples.
  • For MIMO systems, specify u,y as an input/output matrix pair with the following dimensions:
  • u — Ns-by-Nu, where Nu is the number of inputs.
  • y — Ns-by-Ny, where Ny is the number of outputs.
For multiexperiment data, specify data as a pair of Ne-by-1 cell arrays of matrices, where Ne is the number of experiments. The sample times of all the experiments must match.Single Matrix
Specify data as a single real-valued matrix with Ny+Nu columns that contain the output signal values followed by the input signal values. Note that this order is the opposite of the order used for the comma-separated matrix pair form of data. When you specify matrix-based data, the software assumes a sample time of 1 second. You can change the sample time after estimation by setting the property sys.Ts.
Also I want the matrix built up such that each line has a many inputs/outputs as the orders given in teh NLARX.
So in principal I have a x amount of meausurements (number of lines in the matrix) and the number input and output(columns) is equal to the orders
I have written a small code to test this but I get an error message.
Code:
Input_A = (1:5); Output_B = (5:-1:1);
Data = [Output_B Input_A];
Total_Data = [Data; Data];
for counter = 1:50
Total_Data = [Total_Data; Data];
end
sys_1 = nlarx(Total_Data,[5 5 1]);
Error:
>> sys_1 = nlarx(Total_Data,[5 5 0]);
Error using nlarx (line 409)
The number of inputs and outputs of the model must match that of the data.

採用された回答

Cris LaPierre
Cris LaPierre 2023 年 4 月 3 日
編集済み: Cris LaPierre 2023 年 4 月 3 日
I think this line in the Comma-Separated Matrix Pair description is the issue: "specify data as a pair of Ns-element numeric column vectors"
You have specified your Input_A and Output_B as row vectors. I think if you make them column vectors, the error is resolved.
Input_A = (1:5)'; % Transpose so this is a column vector
Output_B = (5:-1:1)'; % Transpose so this is a column vector
Data = [Output_B Input_A];
Total_Data = [Data; Data];
for counter = 1:50
Total_Data = [Total_Data; Data];
end
sys_1 = nlarx(Total_Data,[5 5 1])
sys_1 = Nonlinear ARX model with 1 output and 1 input Inputs: u1 Outputs: y1 Regressors: Linear regressors in variables y1, u1 Output function: Wavelet network with 11 units Sample time: 1 seconds Status: Estimated using NLARX on time domain data "Total_Data". Fit to estimation data: 100% (prediction focus) FPE: 9.651e-21, MSE: 8.348e-21 More information in model's "Report" property.
  11 件のコメント
Leon
Leon 2023 年 4 月 7 日
Hello Rajiv,
Each sample has 15 inputs and 15 outputs. The data are real numbers.
The input and output are rows of each 15 items.
The big issue is that the end of the each output is a little different for each sample.
Therefore I had the idea the run each individual sample through teh NLARX to train.
Hope this info helps, if you have any questions please let me know
Best wishes
Leon
Rajiv Singh
Rajiv Singh 2023 年 4 月 10 日
15 inputs and 15 output channels can be difficult to model using a single system. I would suggest looking closely at the dynamics to see if some channels can be removed (using PLCA, PLS etc). Another thing to try would be to create a separate model for each output.
That said, the easiest way to crate regressors would be using commands such as linearRegressor, polynomialRegressor, etc.
Example:
uvars = "u"+(1:15);
yvars = "y"+(1:15);
R1 = linearRegressor([uvars, yvars],1:3)
R2 = polynomialRegressor(uvars,1:2:7,2,false,true)
R3 = polynomialRegressor(yvars(1:4),1:3,3)
etc.
model = idnlarx(yvars,uvars,[R1;R2;R3],idSigmoidNetwork)
model2 = nlarx(udata, ydata, model)
If you want to use an order matrix to generate the (linear) regressors, please look at the right syntax to use on the idnlarx, or nlarx reference page. Basically, order matrix has the form N = [na nb nk], where na is Ny-by-Ny matrix, and nb/nk are Ny-by-Nu matrices (where Ny denotes the number of outputs, and Nu denotes the number of inputs).
If you run into any errors, please post reproduction steps.
Rajiv

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNonlinear ARX Models についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by