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);

카테고리

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