Use annotation function changing the string dinamycally
12 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Rik
le 7 Fév 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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Characters and Strings dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!