How to plot a rectangle from a single point ?

2 ビュー (過去 30 日間)
Salem
Salem 2021 年 8 月 24 日
コメント済み: Wan Ji 2021 年 8 月 24 日
Is there a way to plot a rectangle from a single point?

採用された回答

Wan Ji
Wan Ji 2021 年 8 月 24 日
編集済み: Wan Ji 2021 年 8 月 24 日
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 件のコメント
Salem
Salem 2021 年 8 月 24 日
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 2021 年 8 月 24 日
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]

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by