Index in position 2 exceeds array bounds (must not exceed 1).

2 ビュー (過去 30 日間)
Chahat Jain
Chahat Jain 2020 年 6 月 16 日
コメント済み: Chahat Jain 2020 年 6 月 24 日
I am getting the following error with my code. I am making a neural network using narxnet and this error is coming in the preparenets function.
Index in position 2 exceeds array bounds (must not exceed 1).
Error in preparets (line 317)
xi = xx(:,FBS+((1-net.numInputDelays):0));
Error in narx (line 6)
[Xs,Xi,Ai,Ts] = preparets(net,x,{},y);
Here is my code:
data = xlsread('data230k1.xlsx');
x = data(1:81000,2)';
y = data(1:81000,1)';
net = narxnet(1:2,1:2,50);
[Xs,Xi,Ai,Ts] = preparets(net,x,{},y);
[net,tr] = train(net,Xs,Ts,Xi,Ai);
nntraintool;
Y = net(Xs,Xi,Ai);
E = gsubtract(Ts,Y);
Can someone help??

回答 (1 件)

Raunak Gupta
Raunak Gupta 2020 年 6 月 22 日
Hi,
The above error is due to the input data x and y not being in the standard cell array format to be inputted to the narxnet. You can use tonndata for converting the vector x and y to cell array. For above code following changes to x and y will help:
data = xlsread('data230k1.xlsx');
x = data(1:81000,2)';
y = data(1:81000,1)';
xCell = tonndata(x,true,false);
yCell = tonndata(y,true,false);
net = narxnet(1:2,1:2,50);
[Xs,Xi,Ai,Ts] = preparets(net,xCell,{},yCell);
[net,tr] = train(net,Xs,Ts,Xi,Ai);
nntraintool;
Y = net(Xs,Xi,Ai);
E = gsubtract(Ts,Y);
  1 件のコメント
Chahat Jain
Chahat Jain 2020 年 6 月 24 日
Thankyou so much. It worked.

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

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by