Display Value in Text Box
61 ビュー (過去 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 で Graphics Object Properties についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!