Easy GUI - Multiple Errors

조회 수: 5 (최근 30일)
Dani
Dani 2012년 10월 17일
I am trying to create a very simple GUI (first time trying to use GUIDE and new to Matlab), but no matter what I do, my code wont run and I cannot figure out what I am doing wrong. Please help!
Here is the code:
x=str2num(get(handles.input,'String'));
y=2*x;
yOut=num2str(y);
set(handles.output,'String',yOut);
guidata(hObject, handles)
Here are the error messages:
Error using hg.figure/set
The name 'String' is not an accessible property for an instance of class
'figure'.
Error in Test>solve_Callback (line 107)
set(handles.output,'String',yOut);
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in Test (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)Test('solve_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
I even tried to follow closely couple GUI tutorials. I have done everything as described, and I still get multiple error messages. What is going on?
Thanks!

답변 (1개)

Matt Fig
Matt Fig 2012년 10월 17일
Apparently
handles.output
is the handle to a figure object. What object were you trying to set the string to? Try this: Call the GUI with an output argument like this:
H = mygui;
Now look at H. This is the handles structure. You can tell which object is which by doing:
get(H.output,'type') % Betting it returns figure.
etc.
  댓글 수: 1
Dani
Dani 2012년 10월 17일
Thanks, Matt!
The output handle was for a Static Text box.
I was not able to figure out exactly why my script(s) was not working, but after I redid everything without changing the default tag names, it somehow worked (still puzzled why).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by