get(x,y) coordinates from rectangle function in matlab

Hi, I use rectangle function to draw a rectangle with two ends curved using following codes:
Rec = rectangle('Position',[1,1,10,5],'Curvature',1);
Will it be possible to get the (x,y) coordinate matrix of Rec?? Thanks for the help.

回答 (2 件)

Walter Roberson
Walter Roberson 2012 年 7 月 18 日

0 投票

What is "the (x,y) coordinate matrix" of Rec ?
You can get() the Position property of Rec to retrieve the [1,1,10,5]

4 件のコメント

Tai-Yen Chen
Tai-Yen Chen 2012 年 7 月 18 日
Hi Walter, What I want is to get the x array and y array so that when I use plot(x,y,'o'), the same rectangle can be ploted out. Hope this clarify what I want.
Walter Roberson
Walter Roberson 2012 年 7 月 18 日
pos = get(Rec, 'Position');
x = [pos(1)+0, pos(1)+pos(3), pos(1)+pos(3), pos(1)+0, pos(1)+0];
y = [pos(2)+0, pos(2)+0, pos(2)+pos(4), pos(2)+pos(4), pos(2)+0];
plot(x,y,'o');
Tai-Yen Chen
Tai-Yen Chen 2012 年 7 月 18 日
Hi Walter, This did not provide the feature of the curved part though. I think I address my question more precisely as how to get the xy of a "curved rectangle"
Walter Roberson
Walter Roberson 2012 年 7 月 18 日
Sorry, I did not notice about that.
I do not know of any method to extract the coordinates. There might be one that is not obvious, but I cannot test that at this time.

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

Ana Gonçalves
Ana Gonçalves 2022 年 5 月 24 日

0 投票

To get the coordinates, just follow the index of the array:
r = rectangle('Position',[20 -3 10 10]);
r.Position(1) % x value
ans = 20
r.Position(2) % y value
ans = -3

カテゴリ

製品

タグ

質問済み:

2012 年 7 月 18 日

回答済み:

2022 年 5 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by