how can I add label to rectangle object ?

32 Ansichten (letzte 30 Tage)
safa BY
safa BY am 3 Aug. 2018
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

Antworten (1)

Eduard Reitmann
Eduard Reitmann am 3 Aug. 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 Kommentare
Eduard Reitmann
Eduard Reitmann am 6 Aug. 2018
You are welcome. I hope it solved your problem.
Sucharitha Chokkappa Gari
Sucharitha Chokkappa Gari am 8 Okt. 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...

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Labels and Annotations finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by