Index in position 2 exceeds array bounds (must not exceed 1).
5 views (last 30 days)
Show older comments
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??
0 Comments
Answers (1)
Raunak Gupta
on 22 Jun 2020
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);
See Also
Categories
Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!