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

1 次查看(过去 30 天)
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 个评论
Todd Flanagan
Todd Flanagan 2011-1-24
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.

请先登录,再进行评论。

采纳的回答

Michelle Hirsch
Michelle Hirsch 2011-1-24
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 个评论
Todd Flanagan
Todd Flanagan 2011-1-24
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"

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by