From: mohammad alquraan on
"Arshad Ali" <a.ali(a)lancaster.ac.uk> wrote in message <hflgf6$cu6$1(a)fred.mathworks.com>...
> Hi
>
> I am struggling to create an Hexagonall grid.I need to find the coordinates falling in hexagonal.These point(coordinates) need to be uniform with one metre distance with each point.any body can help me.


take this code:
clc
x=input('enter the value of x: ');
y=input('enter the value of y: ');
r=input('enter the value of R: ');
n=input('enter the value of N: ');
d=sqrt(3*n)*r

axis([0 x 0 y ])

c=r;
v=30:60:390;
cv=r*cosd(v);
sv=r*sind(v);

for y=0:2:y
for w=0:2:x
line(w*sqrt(3)/2*c+cv,y*1.5*c+sv,'tag','h');
end
end

for m=1:2:y
for k=1:2:x
line(k*sqrt(3)/2*c+cv,m*1.5*c+sv,'tag','h');
end
end