Use annotation function changing the string dinamycally
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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
0 Commenti
Risposta accettata
Rik
il 7 Feb 2019
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)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!