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

6 次查看(过去 30 天)
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

采纳的回答

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

更多回答(0 个)

类别

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