code to draw a cellular topology consisting of 19 hexagonal cells and the rectangle

Status
Not open for further replies.

goldfish300

Newbie level 2
Joined
Mar 7, 2010
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
hi everyone,

i need help creating this shape that consists of 19 hexagonal cells and the rectangle as the following image shown below



i did try the following code but i don't know where i have to fix i tried a lot .

Code:
x_hexagon=[-1 -0.5 0.5 1 0.5 -0.5 -1];
y_hexagon=[0 -sqrt(3)/2 -sqrt(3)/2 0 sqrt(3)/2 sqrt(3)/2 0];

N=2;
M=2;

figure(1)
hold on
for nn=0:N
    for mm=0:M
        plot(x_hexagon+3*nn,y_hexagon+sqrt(3)*mm)
    end
end
for nn=0:N-1
    for mm=0:M-1
        plot(x_hexagon+1.5+3*nn,y_hexagon+sqrt(3)/2+sqrt(3)*mm)
    end
end
hold off
axis equal

thanks anyways for the help i appreciate that .
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…