Borrar filtros
Borrar filtros

Use annotation function changing the string dinamycally

9 visualizaciones (últimos 30 días)
Jose Martinez
Jose Martinez el 7 de Feb. de 2019
Comentada: Jose Martinez el 7 de Feb. de 2019
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

Respuesta aceptada

Rik
Rik el 7 de Feb. de 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)

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by