How to slice inside GUI without error feval(varargin{:})
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Jan
am 17 Sep. 2013
Bearbeitet: Jan
am 17 Sep. 2013
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.
Akzeptierte Antwort
Image Analyst
am 17 Sep. 2013
A likely culprit is that you copied and pasted some test script into your callback function and you used "clear all" in the script. You MUST get rid of clears when you transfer code because that will blow away all variables, including the essential "handles" variable. Please search your entire code for the word clear.
2 Kommentare
Image Analyst
am 17 Sep. 2013
If you use GUIDE, saving it to disk from within GUIDE will update the m-file and fig file. Most smart editors (i.e. not notepad) will recognize this (if you already have the file open) and will ask you if you want to reload the file.
Weitere Antworten (1)
Image Analyst
am 17 Sep. 2013
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).
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!