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

4 次查看(过去 30 天)
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);

类别

Help CenterFile Exchange 中查找有关 Sequence 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