Filter löschen
Filter löschen

How to plot a rectangle from a single point ?

1 Ansicht (letzte 30 Tage)
Salem
Salem am 24 Aug. 2021
Kommentiert: Wan Ji am 24 Aug. 2021
Is there a way to plot a rectangle from a single point?

Akzeptierte Antwort

Wan Ji
Wan Ji am 24 Aug. 2021
Bearbeitet: Wan Ji am 24 Aug. 2021
Hi,
Use rectangle function
rectangle('Position',[0,0,2,4]); % [x_left_down_corner, y_left_down_corner, length, width]
Use axis function make it look clear
axis([-1,3,-1,5])
axis equal
  3 Kommentare
Salem
Salem am 24 Aug. 2021
Thank you, I have a point named for ex. 'dot' which has x and y value. Can I recall the name of a point rather than specify in numbers again the position of the rectangle?
Wan Ji
Wan Ji am 24 Aug. 2021
It is not enough to have x and y, but still length and width are required.
length = 2;
width = 4;
rectangle('Position',[ex.x, ex.y, length, width]); % [x_left_down_corner, y_left_down_corner, length, width]

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by