Plot a rectangle inside of a rectangle.

조회 수: 10 (최근 30일)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA 2022년 2월 1일
댓글: ANANTA BIJOY BHADRA 2022년 2월 2일
How can I plot a rectangle inside of a rectangle. I have a rectangle of 50 width and 20 length. I need a rectangle inside with 15 width and 10 length. How to code it? I need matlab code or suggations for this.

채택된 답변

Image Analyst
Image Analyst 2022년 2월 2일
Have you tried the rectangle function?
rectangle('Position', [5,2,50,20], 'EdgeColor', 'r', 'LineWidth', 2);
hold on;
rectangle('Position', [15,5,15,10], 'EdgeColor', 'b', 'LineWidth', 2);
grid on;
axis equal
Adjust numbers to get the placement you want.

추가 답변 (1개)

Matt J
Matt J 2022년 2월 1일
편집: Matt J 2022년 2월 1일
One way,
V=[-1 -1;
+1 -1;
+1 +1 ;
-1 +1]/2;
p=[polyshape(V.*[50,20]), polyshape(V.*[15,10])];
plot(p)

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by