Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commento
Todd Flanagan
Todd Flanagan il 24 Gen 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.

Accedi per commentare.

Risposta accettata

Michelle Hirsch
Michelle Hirsch il 24 Gen 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 Commento
Todd Flanagan
Todd Flanagan il 24 Gen 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"

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by