Hello all,

here the programme I think there are some mistakes couldnot know where please any comment will be helpful:

# Firstly, set the size limit for the grid, which shall define how many

# points there are in both the vertical and horizontal direction

size=40;

# limit is a variable used to set an unobtainable upper bound

limit=size+1;

# x defined, starting at 1, and two other variables ud (upper diagonal) and

# dd (downward diagonal) begin at 0. All three are used to iterate through

# line creation

x=1;

ud=0;

dd=0;

# Iteration through x, using the line function to create a number of

# horizontal lines up to the limit point

while(x<(limit))

line([0, size], [x, x]);

x=x+1;

end

# Now iterating through the diagonals pointing upwards, using two sets of

# lines, both starting from the line going through the origin. The first

# iterates through the lines that pass through positive x values at y=0,

# the second iterates through the lines passing through negative x values

# at y=0

# ud must be increased by 2 each time to ensure that equilateral triangles

# are formed.

while(ud<(limit))

line([(ud), (size)], [0, (size-ud)]);

line([0, (size-ud)], [(ud), (size)]);

ud=ud+2;

end

# Similar to before, except this time iterating through downward pointing

# diagonals.

while(dd<(limit))

line([(dd), 0], [0, (dd)]);

line([(size), (dd)], [(dd), (size)]);

dd=dd+2;

end

# xvector and yvector set up as two vectors holding x and y co-ordinates of

# points respectively.

xvector = zeros(1, limit);

yvector = zeros(1, limit);

# Reinitiallising x and y values for iterative purposes.

x=0;

y=0.5;

n=1;

# The program now iterates through potential y values for the potential

# points. Then it tests the value of y to see what orientation the lattice

# is at that point, then randomly selects x values to enter, iterating

# between all the possible x values in the orientation before moving on to

# the next y value.

while(y<size)

if(mod(y,1)==0.5)

x=0.5;

while(x<size)

z=rand;

if(z>0.5)

xvector(n) =x;

yvector(n) =y;

n=n+1;

end

x=x+1;

end

elseif(mod(y,2)==1)

x=0;

while(x<size)

z=rand;

if(z>0.5)

xvector(n) =x;

yvector(n) =y;

n=n+1;

end

x=x+2;

end

else

x=1;

while(x<size)

z=rand;

if(z>0.5)

xvector(n) =x;

yvector(n) =y;

n=n+1;

end

x=x+2;

end

end

y=y+0.5;

end

# The program then enters the two co-ordinate vectors saved previously into

# the scatter function.

hold;

scatter(xvector, yvector);