error ??? Index exceeds matrix dimensions.

1 回表示 (過去 30 日間)
Muhamad Jaliluddin Mazlan
Muhamad Jaliluddin Mazlan 2013 年 12 月 5 日
回答済み: Greg Heath 2013 年 12 月 6 日
%
--------------------------------------------------------------------------
%define input and output for training
in=d(1:40,1:1000);
ou=d(41:40,1:1000);
trainInput= d(1:40,201:1000); % input for training
trainOutput= d(41:40,201:1000); % output for training
%--------------------------------------------------
% training the MLP Neural network
% newff(input, target,[hidden layer1 hiddenlayer2 output],{transferFunction1 transferFunction2 transferFunction3});
% transferFunction defult for hidden layer is tansig but here use logsig
% and purelin is default transferFunction for output layer
net = newff(minmax(in),ou,[10 10 4],{'logsig' 'logsig' 'purelin'});
%--------------------------------------------------------------------------
% Setting the parameters for training
net.trainParam.epochs = 1000; %set the maximum number of epochs to train
net.trainParam.goal = 0.02; %sum-squared error goal.
%--------------------------------------------------------------------------
% training the MLP by using a a train function
net = train(net,trainInput,trainOutput);
%--------------------------------------------------------------------------
% To draw the result making the testing
testInput=d(1:40,1:200); % extract certain column for testing input
testResult1=sim(net,testInput); % simulate the MLP network by using a sim function
testResult1 = testResult1';
trainOutput2= d(1:40,1:200);
??? Index exceeds matrix dimensions.
above is my code for fold 1 (train set is 201-1000, test set is 1-200) i use dataset 1000x40 double Any expert can u help me...thank you!!!
  1 件のコメント
kjetil87
kjetil87 2013 年 12 月 5 日
I didnt check the entire code but It migh be because of
ou=d(41:40,1:1000);
this is and empty matrix... Correct syntax is
ou=d(41:-1:40,1:1000);

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

採用された回答

Greg Heath
Greg Heath 2013 年 12 月 6 日
Did it ever occur to you that it is self defeating to include code with a data set that is not accessible to those who want to help you?
In the future try your code on a MATLAB data set before posting. That way you can separate code errors from data errors and get a headstart on receiving focused help.
help nndatasets
doc nndatasets
Either use all of the chosen MATLAB dataset or a subset of it to best match the size of your data.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%define input and output for training
in=d(1:40,1:1000);
ou=d(41:40,1:1000);
'1. ERRONEOUS INDEXING'
trainInput= d(1:40,201:1000); % input for training
trainOutput= d(41:40,201:1000); % output for training
'2.ERRONEOUS INDEXING'
%--------------------------------------------------
% training the MLP Neural network
% newff(input, target,[hidden layer1 hiddenlayer2 output], ...
% {transferFunction1 transferFunction2 transferFunction3});
% transferFunction defult for hidden layer is tansig but here use logsig
% and purelin is default transferFunction for output layer
net = newff(minmax(in),ou,[10 10 4],{'logsig' 'logsig' 'purelin'});
'3. DOUBLY OBSOLETE FUNCTION. USE FITNET.'
'4. ONE HIDDEN LAYER IS SUFFICIENT'
'5. BIPOLAR TANSIG IS BETTER FOR HIDDEN LAYERS THAN UNIPOLAR LOGSIG'
'6. 4 OUTPUT NODES IS ERRONEOUS'
%--------------------------------------------------------------------------
% Setting the parameters for training
net.trainParam.epochs = 1000; %set the maximum number of epochs to train
'7. epochs = 1000 IS A DEFAULT. WHY BOTHER?'
net.trainParam.goal = 0.02; %sum-squared error goal.
'8. WHAT IS THE RATIONALE FOR THIS CHOICE??...(I ASSUME YOU MEANT MSE INSTEAD OF SSE)'
%--------------------------------------------------------------------------
% training the MLP by using a a train function
net = train(net,trainInput,trainOutput);
%--------------------------------------------------------------------------
% To draw the result making the testing
testInput=d(1:40,1:200); % extract certain column for testing input
testResult1=sim(net,testInput); % simulate the MLP network by using a sim function
testResult1 = testResult1';
trainOutput2= d(1:40,1:200);
'9.ERRONEOUS INDEXING'
THANK YOU FOR FORMALLY ACCEPTING MY ANSWER
GREG

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by