Use annotation function changing the string dinamycally

12 ビュー (過去 30 日間)
Jose Martinez
Jose Martinez 2019 年 2 月 7 日
コメント済み: Jose Martinez 2019 年 2 月 7 日
Hi,
I want to create a text in a figure but outside the axis, but it has to change with the time according to some pressure sensors. I am using "annotation" function:
loop:
steps=steps+1;
txt = ['Steps number: ' num2str(step_number) ' units'];
annotation('textbox',[.9 .5 .1 .2],'String',txt,'EdgeColor','none');
The issue is that the value it's being overlapped each iteration. Could someone help please? Thanks

採用された回答

Rik
Rik 2019 年 2 月 7 日
Create the annotation once, and then only change the string property inside the loop.
figure(1)
txt='';
h_annot=annotation('textbox',[.9 .5 .1 .2],'String',txt,'EdgeColor','none');
for steps=1:5
step_number=steps;
txt = sprintf('Steps number: %d units',step_number);
set(h_annot,'String',txt)
drawnow%force graphics update, pause(0.001) will work as well
for k=1:1e6
1+1;%have some calculation to simulate your actual processing time
end
end
close(1)
  1 件のコメント
Jose Martinez
Jose Martinez 2019 年 2 月 7 日
It works brilliant! Thank you so much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by