How to slice inside GUI without error feval(varargin{:})

6 vues (au cours des 30 derniers jours)
Lennart
Lennart le 17 Sep 2013
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 commentaires
Lennart
Lennart le 17 Sep 2013
Modifié(e) : Lennart le 17 Sep 2013
Added the whole error. I must note that I have tried different approaches which all resulted in different errors, except the gui_mainfcn error, that one is in all of them. You think the colon is not the problem? This gives me hope :)
Jan
Jan le 17 Sep 2013
Modifié(e) : Jan le 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.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 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 commentaires
Lennart
Lennart le 17 Sep 2013
While I got these errors, I made a lot of changes and nothing seemed to work. When I had to go to a meeting I shut down MatLab. Then after I returned, started MatLab again, it worked! No idea what the problem was. I use sublime text, maybe MatLab GUIDE only works if I save changes with the MatLab editor?
Image Analyst
Image Analyst le 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.

Connectez-vous pour commenter.

Plus de réponses (1)

Image Analyst
Image Analyst le 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).
  1 commentaire
Lennart
Lennart le 17 Sep 2013
Ah yes, sorry I showed the code for the second step which shows slices from the 3D data. Will correct it now.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by