How I can use some object method for uicontrol callback function?

6 vues (au cours des 30 derniers jours)
Zak Kankin
Zak Kankin le 13 Jan 2016
Commenté : Zak Kankin le 13 Jan 2016
For example, I want create a figure in object method, but how than I can call some method from this figure?
classdef test
methods
function disp(obj)
disp('hello')
end
function makeFig(obj)
figure;
uicontrol('style','pushbutton','callback',@obj.disp) % don't work
end
end
end

Réponse acceptée

Walter Roberson
Walter Roberson le 13 Jan 2016
Change @obj.disp to
@(src,event) obj.disp
Callbacks must accept the two parameters automatically provided by MATLAB.

Plus de réponses (0)

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