필터 지우기
필터 지우기

how to extract (x-y) coordinates after using the RECTANGLE function

조회 수: 4 (최근 30일)
Federico De Bianchi
Federico De Bianchi 2020년 3월 1일
답변: Guillaume 2020년 3월 1일
Hi,
I need to draw rectangles, given a center, an x_dimension and an y_dimension. I know that there is the specific function "rectangle" to do this, but in the programm I'm modifying it's mandatory to have the rectangles as sets of (x,y) coordinates ( so that plot(x,y) gives the desidered rectangle).
Is there a generic way to excract the coordinates from the rectangle function?
  댓글 수: 2
Guillaume
Guillaume 2020년 3월 1일
Your question is a bit puzzling. The rectangle function is used to draw a rectangle in a figure. You give it the coordinates of the rectangle you want to draw. You can't call rectangle if you don't have a rectangle coordinates.
Federico De Bianchi
Federico De Bianchi 2020년 3월 1일
let me be more clear. In order to use the rectangle function you need to give, as input, the left corner coordinate (x,y), the width and the height. I have all these information.
But the problem is that I need to have a vector of coordinates X and a vector of coordinates Y, that doing plot(X,Y) give the same rectangal i would obtain by using the function. These two vectors have also to take into account possible rotations of the rectangle with respect to one corner

댓글을 달려면 로그인하십시오.

답변 (1개)

Guillaume
Guillaume 2020년 3월 1일
%r: [X, Y, width, height] description of a rectangle, that would be pass to rectangle with: rectangle('Position', r)
X = [r(1), r(1)+r(3), r(1)+r(3), r(1), r(1)];
Y = [r(2), r(2), r(2)+r(4), r(2)+r(4), r(2)];
plot(X, Y)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by