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 CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by