Filter löschen
Filter löschen

Plotting the vertex based hexagon hierarchical structure.

1 Ansicht (letzte 30 Tage)
Nupur
Nupur am 7 Jul. 2023
Bearbeitet: Dyuman Joshi am 7 Jul. 2023
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 Kommentare
Nupur
Nupur am 7 Jul. 2023
yes, it is similar.However this answer didnt work for me.
Dyuman Joshi
Dyuman Joshi am 7 Jul. 2023
Bearbeitet: Dyuman Joshi am 7 Jul. 2023
@Nupur please check my updated answer on the original thread.
I can post the answer here as well, if you wish.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 7 Jul. 2023
Bearbeitet: Matt J am 7 Jul. 2023
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

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by