Creation of multiple rectangles
显示 更早的评论
Hallo,
i have got a question to my code. This function creates only 10 rectangles, so i would like to make it more efficient, that this is not only working for 10. Furthermore, i would like to change the way it is stored in the array. As you can see my array is reallly long, and only for 10 rectangles.
Any help would be nice.
x and y are both 10x1 coordinates of another figure, the rectangles are on the edge of this figure.
function S = sBox(x,y)
%sBox creates the secondary box out of coordinates
S1 = [x(1) y(1); x(2) y(1); x(2) y(2); x(1) y(2); x(1) y(1)];
S2 = [x(2) y(2); x(3) y(2); x(3) y(3); x(2) y(3); x(2) y(2)];
S3 = [x(3) y(3); x(4) y(3); x(4) y(4); x(3) y(4); x(3) y(3)];
S4 = [x(4) y(4); x(5) y(4); x(5) y(5); x(4) y(5); x(4) y(4)];
S5 = [x(5) y(5); x(6) y(5); x(6) y(6); x(5) y(6); x(5) y(5)];
S6 = [x(6) y(6); x(7) y(6); x(7) y(7); x(6) y(7); x(6) y(6)];
S7 = [x(7) y(7); x(8) y(7); x(8) y(8); x(7) y(8); x(7) y(7)];
S8 = [x(8) y(8); x(9) y(8); x(9) y(9); x(8) y(9); x(8) y(8)];
S9 = [x(9) y(9); x(10) y(9); x(10) y(10); x(9) y(10); x(9) y(9)];
S10= [x(10) y(10); x(1) y(10); x(1) y(1); x(10) y(1); x(10) y(10)];
S = [x(1) y(1)
x(2) y(1)
x(2) y(2)
x(1) y(2)
x(1) y(1)
x(2) y(2)
x(3) y(2)
x(3) y(3)
x(2) y(3)
x(2) y(2)
x(3) y(3)
x(4) y(3)
x(4) y(4)
x(3) y(4)
x(3) y(3)
x(4) y(4)
x(5) y(4)
x(5) y(5)
x(4) y(5)
x(4) y(4)
x(5) y(5)
x(6) y(5)
x(6) y(6)
x(5) y(6)
x(5) y(5)
x(6) y(6)
x(7) y(6)
x(7) y(7)
x(6) y(7)
x(6) y(6)
x(7) y(7)
x(8) y(7)
x(8) y(8)
x(7) y(8)
x(7) y(7)
x(8) y(8)
x(9) y(8)
x(9) y(9)
x(8) y(9)
x(8) y(8)
x(9) y(9)
x(10) y(9)
x(10) y(10)
x(9) y(10)
x(9) y(9)
x(10) y(10)
x(1) y(10)
x(1) y(1)
x(10) y(1)
x(10) y(10)];
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Polygons 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!