-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathcellular2.m
More file actions
27 lines (27 loc) · 733 Bytes
/
cellular2.m
File metadata and controls
27 lines (27 loc) · 733 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
m=20;
n=20;
r=1;
r2=r*cos(pi/6);
cellular_network(1,1).x=2;
cellular_network(1,1).y=2;
for i=1 : m
if (i >= 2)
cellular_network(i,1).x=cellular_network(i-1,1).x;
cellular_network(i,1).y=cellular_network(i-1,1).y+2*r2;
end
for j=2 : n
if (mod(j,2)==0)
cellular_network(i,j).x=cellular_network(i,j-1).x+2*r2*cos(pi/6);
cellular_network(i,j).y=cellular_network(i,j-1).y+2*r2*sin(pi/6);
else
cellular_network(i,j).x=cellular_network(i,j-1).x+2*r2*cos(pi/6);
cellular_network(i,j).y=cellular_network(i,j-1).y-2*r2*sin(pi/6);
end
end
end
axis equal;
% axis([0 40 0 40]);
axis off;
hold on;
draw_cellular(cellular_network,r);
hold off;