Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
Nitin Samuel
Nitin Samuel le 18 Déc 2012
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?

Réponses (3)

Muruganandham Subramanian
Muruganandham Subramanian le 18 Déc 2012
Modifié(e) : Muruganandham Subramanian le 18 Déc 2012
Variable 'T' should be converted to string using num2str(T) first, before calling. Have you done this?
  1 commentaire
Nitin Samuel
Nitin Samuel le 18 Déc 2012
yes i used
set(handles.edit21,'String',num2str(T));
still same error...

Connectez-vous pour commenter.


Jan
Jan le 18 Déc 2012
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 commentaire
Nitin Samuel
Nitin Samuel le 18 Déc 2012
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..

Connectez-vous pour commenter.


Ilham Hardy
Ilham Hardy le 18 Déc 2012
Did you use any clear -command family in your GUIDE code?
Such as:
clear
clearvars
clear all
  1 commentaire
Nitin Samuel
Nitin Samuel le 18 Déc 2012
Modifié(e) : Nitin Samuel le 18 Déc 2012
I havent.Should I? But how does adding that help?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Interactive Control and Callbacks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by