Borrar filtros
Borrar filtros

how can I add label to rectangle object ?

33 visualizaciones (últimos 30 días)
safa BY
safa BY el 3 de Ag. de 2018
Comentada: Sucharitha Chokkappa Gari el 8 de Oct. de 2020
My code : rect=rectangle('Position',pos);
draggable(rect); set(rect,'FaceColor','none','EdgeColor','g','LineWidth',6);
And now I want to add a label to the rectangle

Respuestas (1)

Eduard Reitmann
Eduard Reitmann el 3 de Ag. de 2018
I am not familiar with the 'draggable' function, but this should give you a text box in the middle of the square.
text(pos(1)+pos(3)/2,pos(2)+pos(4)/2,'Title','HorizontalAlignment','center')
  5 comentarios
Eduard Reitmann
Eduard Reitmann el 6 de Ag. de 2018
You are welcome. I hope it solved your problem.
Sucharitha Chokkappa Gari
Sucharitha Chokkappa Gari el 8 de Oct. de 2020
Sir,
text(pos(1)+pos(3)/2,pos(2)+pos(4)/2,'Title','HorizontalAlignment','center')
this works for me
How do I do if I have 4 rectangles being plotted in loop and I want to name them as rect1, rect2...

Iniciar sesión para comentar.

Categorías

Más información sobre Labels and Annotations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by