error with set handles.edit1 and function (varargin)

1 vue (au cours des 30 derniers jours)
Diego
Diego le 16 Fév 2012
i'm making a GUI, i want to get the current point of axes1 and pass it to a textbox edit1, but i get the followin error:
??? Undefined variable "handles" or class "handles.edit1".
Error in ==> GUI>draggingFcn at 166
set(handles.edit1,'String','helo')
??? Error while evaluating figure WindowButtonMotionFcn
here is my part of my code:
function draggingFcn(varargin)
pt=get(gca,'CurrentPoint');
A=num2str(pt(1,1));
set(handles.edit1,'String',A)

Réponse acceptée

Walter Roberson
Walter Roberson le 16 Fév 2012
How did your draggingFcn get to be varargin, I wonder? Did you create that signature yourself, or did you have GUIDE create it for you?
Anyhow, without getting in to the question of whether handles is even being passed to your function, the fix you need is
function draggingFcn(varargin)
handles = guidata(ancestor(varargin{1},'figure'));
pt=get(gca,'CurrentPoint');
A=num2str(pt(1,1));
set(handles.edit1,'String',A)
  1 commentaire
Diego
Diego le 16 Fév 2012
IT WORKS perfectly. tank you so much.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB 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