Plotting the vertex based hexagon hierarchical structure.
이전 댓글 표시
I want to plot a closed hexagon, however i got the belwo when i directly pass on the x and y coorindites to plot it.

Please anyone who could help out
댓글 수: 3
Steven Lord
2023년 7월 7일
Is this related to https://www.mathworks.com/matlabcentral/answers/1991108-plotting-using-given-coordinates?s_tid=prof_contriblnk for which you've accepted an answer? If it is, either add a reference to that previous question to provide context (which I guess I just did) or add more information to that question and we can close this question as a duplicate of that previous one.
Nupur
2023년 7월 7일
Dyuman Joshi
2023년 7월 7일
편집: Dyuman Joshi
2023년 7월 7일
@Nupur please check my updated answer on the original thread.
I can post the answer here as well, if you wish.
답변 (1개)
P=rotate(nsidedpoly(6,'SideLength',1),30); %1 hexagon
plot(P,'FaceColor','none'); axis equal
P=fcopy(P,sqrt(3)*[1,0], 0:7 ); %1 row of hexagons
plot(P,'FaceColor','none'); axis equal
P=fcopy(P,sqrt(3)*[cosd(60), sind(60)], 0:1); %2 rows of hexagons
plot(P,'FaceColor','none'); axis equal
P=scale(fcopy(P,3*[0,1], 0:3 ),5); %Full plot
plot(P,'FaceColor','none'); axis equal
function P=fcopy(p,dir,c)
fn=@(s) translate(p,s*dir);
P=arrayfun(fn,c,'uni',0);
P=[P{:}];
end
카테고리
도움말 센터 및 File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



