Display Value in Text Box
36 次查看(过去 30 天)
显示 更早的评论
I am trying to display the value of a in a text box.
a=trapz(cP6-cP7);
str='Area Swept: %d';
annotation('textbox',[0.3 0.5 0.3 0.3],'String',str,'FitBoxToText','on');
0 个评论
采纳的回答
Rik
2019-3-5
You need to transform your value to text using either sprintf or num2str:
a=trapz(cP6-cP7);
str=sprintf('Area Swept: %d',a);
annotation('textbox',[0.3 0.5 0.3 0.3],'String',str,'FitBoxToText','on');
2 个评论
Rik
2019-3-5
You can store a handle to the annotation object in a variable, after which you can modifiy the properties as you need to.
%example:
a=10;
figure(1),clf(1)%clear figure (use only for debugging)
str=sprintf('Area Swept: %d',a);
h_annot=annotation(...
'textbox',[0.3 0.5 0.3 0.3],...
'String',str,...
'FitBoxToText','on');
for n=1:10
%move it around randomly
set(h_annot,...
'position',[0.1+rand/5 0.4+rand/5 0.3 0.3],...
'FitBoxToText','on')
pause(1/3)
end
If my answer solved your problem, please consider marking it as accepted answer.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!