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

3 views (last 30 days)
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 Comment
Todd Flanagan
Todd Flanagan on 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.

Sign in to comment.

Accepted Answer

Michelle Hirsch
Michelle Hirsch on 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 Comment
Todd Flanagan
Todd Flanagan on 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"

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!