Problem with the "get" function to get dat from a handles structure in a GUI

3 vues (au cours des 30 derniers jours)
I am working on a GUI and have some trouble. Here is the code that I am using:
function etireur_compresseur_gui_OpeningFcn(hObject, eventdata, handles, varargin)
set (handles.input_lambda,'String','1057e-9')
handles.lambda = str2double(get(handles.input_lambda,'String'));
% Update handles structure
guidata(hObject, handles);
Now here is the problem : when I type in the command window
get(handles.input_lambda)
Everything is fine and no pb but when I type :
get(handles.lambda)
Then I get this error :
??? Error using ==> get
Invalid handle object.
Does anyone have an idea?
  1 commentaire
Todd Flanagan
Todd Flanagan le 24 Jan 2011
Hi Mathieu, I moved your answer to a comment on Scott's answer. That's a good place for that sort of back and forth.

Connectez-vous pour commenter.

Réponse acceptée

Michelle Hirsch
Michelle Hirsch le 24 Jan 2011
handles.lambda is a number, not a graphics object, so get won't work on it. Just type handles.lambda at the command line instead of get(handles.lambda) to see it's contents.
Here is the line that is setting handles.lambda to a number instead of an object.
handles.lambda = str2double(get(handles.input_lambda,'String'))
  1 commentaire
Todd Flanagan
Todd Flanagan le 24 Jan 2011
Mathieu says, "Thanks for the answer! The thing here is that I try to use the datas contained in the handle structure in another sub GUI. So in the sub GUI I now use this code to make it work properly:
mainGUIFigureHandle = etireur_compresseur_gui;
mainGUIdata = guidata(mainGUIFigureHandle);
handles.lambda = str2double(get(mainGUIdata.input_lambda,'String'));
Using directly the handles.lambda from the main GUI in the sub GUI would have prevented me to do the string to double conversion. But if it's the only way then fine, it's not a big deal... Thanks anyway"

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by