f = uifigure;
ax = axes(f, 'Position', [0.1, 0.6, 0.8, 0.4]);
b = uibutton(f,...
'Position', [0.1*f.Position(3), 0.1*f.Position(4), 0.8*f.Position(3), 0.4*f.Position(4)],...
'ButtonPushedFcn', @buttonpress);
h = images.roi.Ellipse(ax, 'Center', [0.5 0.5],...
'Semiaxes', [0.3 0.3]);
l = addlistener(h, 'MovingROI', @allevents);
b.ButtonPushedFcn = {b.ButtonPushedFcn, l};
function allevents(~, evt)
evname = evt.EventName;
if strcmp(evname, 'MovingROI')
disp(['ROI moving Current Center: ' mat2str(evt.CurrentCenter)]);
disp(['ROI moving Current SemiAxes: ' mat2str(evt.CurrentSemiAxes)]);
end
end
function buttonpress(src, ~, l)
if nargin > 2
delete(l)
end
end
Best Answer