필터 지우기
필터 지우기

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