Info

この質問は閉じられています。 編集または回答するには再度開いてください。

What is Index exceeds matrix dimensions.error?

1 回表示 (過去 30 日間)
Subhankar  Singha
Subhankar Singha 2015 年 4 月 23 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Sir I am facing this error. I cannot understan what it really means.
Error in singha>VALIDATE_Callback (line 506) s2 = std2(cimg(:,:,2));
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in singha (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)singha('VALIDATE_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
  1 件のコメント
Stephen23
Stephen23 2015 年 4 月 26 日

回答 (1 件)

Adam
Adam 2015 年 4 月 23 日
編集済み: Adam 2015 年 4 月 23 日
Arrays/matrices have a dimension which you can check by
size( myArray );
Indexing into an array using an index greater than the size in the specified dimension leads to this error.
e.g. if you have a 3*3 array, myArray , both the following will yield this error:
myArray(3,4); % 4 exceeds the 2nd dimension size
myArray(2,2,3); % 3 exceeds the 3rd dimension size as there is no 3rd dimension
From this you should be able to see what is going wrong in your own code by debugging and since this is something fundamental to learn in Matlab it is better for your learning that you locate it rather than someone point out the error.
  3 件のコメント
Subhankar  Singha
Subhankar Singha 2015 年 4 月 26 日
Sir the error says this Attempted to access test(1,495,2); index out of bounds because size(test)=[512,512,1]. No matter what i do the third dimension in test always exceeds the 3rd value , which is "2" in this case. I am attaching me new codes.Sir please look at the code, I will be very thankful to you if you coorect the entire code. Looking forward to your much needed help.
Adam
Adam 2015 年 4 月 27 日
You have already discovered the cause of the error yourself. Finding a solution for it is down to you working out what your matrices should be and what size they should be rather than something that can just be fixed by Matlab knowledge alone.

Community Treasure Hunt

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

Start Hunting!

Translated by