Replace a subplot title on a figure from another function in appdesigner
显示 更早的评论
Hello, In appdesigner I have created an image on a subplot in a figure:
f1=figure('position',pos);
s1=subplot(1,3,1)
Im using a roi.ellipse object with an event listener, to allow the user to move and resize the ellipse.(all works fine)
h = images.roi.Ellipse(gca,'Center',[xpeak xpeak2],'Semiaxes',[1.699*fwhm/2 1.699*fwhm2/2],'Color','g','StripeColor','r','LineWidth',1); %1/e^2 = 1.699xfwhm
el=addlistener(h,'ROIMoved',@app.allevents);
what I want to do, is in the function "allevents" where I obtain the moved ellipse parameters, is to calculate the area and then replace the title of the sublot s1 with the area. But I'm having issues with changing the title.
function allevents(app,src,evt)
evname = evt.EventName;
switch(evname)
case{'MovingROI'}
disp(['ROI moving Current Center: ' mat2str(evt.CurrentCenter)]);
disp(['ROI moving Current SemiAxes: ' mat2str(evt.CurrentSemiAxes)]);
case{'ROIMoved'}
disp(['ROI moved Current Center: ' mat2str(evt.CurrentCenter)]);
disp(['ROI moved Current SemiAxes: ' mat2str(evt.CurrentSemiAxes)]);
a=evt.CurrentSemiAxes(1)
b=evt.CurrentSemiAxes(2)
area=pi*app.a*app.b
title(s1,['Area=',num2str(area,'%.1f')])
end
end
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!