How do I solve the error: Undefined variable "handles" or class "handles.edit21"?

2 次查看(过去 30 天)
I have developed a GUI.When the pushbuttton is clicked, the calculation is done and the calculated number which is stored in the variable 'T' must be displayed in an edit box as the output. I have used
set(handles.edit21,'String',T);
in the pushbutton callback. However when i click the pushbutton, I get the following error:
Undefined variable "handles" or class "handles.edit21".
How can I rectify this?

回答(3 个)

Muruganandham Subramanian
编辑:Muruganandham Subramanian 2012-12-18
Variable 'T' should be converted to string using num2str(T) first, before calling. Have you done this?

Jan
Jan 2012-12-18
Whne the variable handles is unknown, you have to define it. This is actually trivial, so I'm not sure what the problem exactly is. A guess:
handles = guidata(hObject);
  1 个评论
Nitin Samuel
Nitin Samuel 2012-12-18
Actually Im new to matlab so dont knw much...In the beginning you have :
handles = guihandles(fig);
guidata(fig, handles);
I tried adding in hObject with 'fig' & 'handles', it says
Undefined function or variable 'hObject'.
Where should I put it? Really appreciate your help..

请先登录,再进行评论。


Ilham Hardy
Ilham Hardy 2012-12-18
Did you use any clear -command family in your GUIDE code?
Such as:
clear
clearvars
clear all

类别

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