Unable to solve Indexing error in matlab
1 view (last 30 days)
Show older comments
Sir I am facing this problem..I ave tried a loy but I am not able to solve it. It is showing this error
Index exceeds matrix dimensions.
Error in singha>VALIDATE_Callback (line 504) 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 Comment
Answers (1)
Stephen23
on 25 Apr 2015
Edited: Stephen23
on 25 Apr 2015
Use the debugging tools and check the size of the matrix just before the error occurs:
It is likely that you will find that the array only has one page (i.e. along the third dimension), so the indexing (cimg(:,:,2) will cause the error because there is no second page to that array.
This may be because you are confusing different image types, which can have different numbers of dimensions. You should read the documentation carefully and check how many dimensions the arrays have:
Otherwise the error must be in your algorithm somewhere. Note that without the accompanying .FIG file no one can run the code that you generated using GUIDE.
5 Comments
Image Analyst
on 26 Apr 2015
This is code I gave you in your other question, but you've commented it out for some reason. Please please please decide whether you want to work with a color image or a gray scale image, or both. Which is is? I would think that since it's an mri image you want it to be grayscale. However that's not what you asked in your other question where you asked how to create a color image. Then check what you have and make any conversion if needed.
See Also
Categories
Find more on Image Processing Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!