# How to replicate a hexagon pattern in a given area of 100x100

3 Ansichten (letzte 30 Tage)
Arsal15 am 5 Dez. 2015
Kommentiert: Arsal15 am 16 Dez. 2015
Hi all,
I need the guidance from experts as I am little bit confused about how to replicate this hexagon pattern as shown in Figure in an area of 100x100. Because I am not getting how to apply for loop in height and width so that I can get a pattern of hexagons in 100x100.
Need your guidance. My code can be found in attached Replicating_cell_layout1.m file.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Rick Rosson am 5 Dez. 2015
Bearbeitet: Rick Rosson am 5 Dez. 2015
function draw_pattern
r = 2;
dx = r;
dy = r*sin(pi/3);
figure;
axes;
hold on;
for x = 0:dx:100
for y = 0:dy:100
aHex = new_hexagon([x y],r);
plot(aHex(:,1),aHex(:,2),'color','blue');
end
end
end
N = 6;
phi = (2*pi/N)*(0:N)';
aHex = ones(N+1,1)*center + radius * [ cos(phi) sin(phi) ];
end
##### 4 Kommentare2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden
Rick Rosson am 6 Dez. 2015
I accidentally made two mistakes in my code. Maybe you can try to find the errors and then correct them. It's a good exercise for learning how to program in MATLAB.
Arsal15 am 16 Dez. 2015
Hi,
I want to put a plus marks on the black spotted points and its a fix pattern and I want this to be generic so that if I change the size the plus marks can be printed in the same pattern.
Can anyone guide me about some logic or for loop iteration....

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Clustering finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by