How to slice inside GUI without error feval(varargin{:})
Show older comments
So I am making a GUI using GUIDE. The first step I want to make is to reduce my 11D array dataset to a 3D array. This is no problem normally, I just slice it like data(:,:,1,:,1,1). However when I let a UI element call that as in tempdat = data(:,:,1,:,1,1) I receive the error :
Undefined function or variable 'handles'.
Error in simple>slider2_Callback (line 194)
image(handles.data(1:handles.rows,1:handles.cols, temp));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in simple (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)simple('slider2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I have tried many other ways to get the colon in there, but I always get stuck on an error. The above error is the error of one of my tries. The thing all errors have in common is the "Error in gui_mainfcn (line 96) feval(varargin{:});" part. When I check for handles it does exist. How to slice in GUI? I dont understand why it does not work. Is this really a problem with the colon or is it more likely something else?
3 Comments
Jan
on 17 Sep 2013
Please post the complete error message. Without knowing the full message, most of all the description of the problem, and the relevant part of the code, a useful answer is not possible.
Please insert the additional information by editing the question, not by hiding the details in a comment or pseudo-answer. Thanks.
The error message mean, that the variable "handles" does not exist. This has not relation to a colon operator.
There could be a variety of reasons. It would be easy to find the problem with the debugger:
dbstop if error
Then run the program again until it stops at the error. Then look in the lines above, why "handles" is not existing. Did you use another name in the input arguments? Did you clear it? Did the calling function provide data for this input? While you can check this easily by your own, we cannot guess it, because we cannot see the code.
Please note, that there is no connection between "tempdat = data(:,:,1,:,1,1)" and the shown error message. So this is confusing only.
Accepted Answer
More Answers (1)
Image Analyst
on 17 Sep 2013
0 votes
Try putting indexes or : for all 11 dimensions, not just the 6 you used. To get a 3D matrix you should have numbers (or specific numerical ranges) for 8 indexes (not 4) and colons for 3 indexes (not 2).
Categories
Find more on Matrix Indexing 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!