Sorry, code is:
ct=11;
while n<nmax
for n=n:nmax;
rn=(sqrt(2*n*f*lambda+n^2*lambda^2));
w=(lambda*f/2/rn);
d=1.53096*w;
phi=asin((d/2)/rn);
num=floor(fillfactor/phi);
gap=2*(pai/(num-1)-phi);
a=rand;
theta(1)=pai*a;
x(1)=1000000*rn*cos(theta(1))
y(1)=1000000*rn*sin(theta(1))
for i=2:num;
theta(i)=theta(i-1)+gap+2*phi;
x(i)=1000000*rn*cos(theta(i));
y(i)=1000000*rn*sin(theta(i));
end;
ct=ct+1
fileID = fopen('matrix.txt','a+' );
formatSpec = 'x%6.0fy%6.0fD03*\n'
fprintf(fileID,'%7s\n','G54D');
fprintf(fileID,'x%6.0fy%6.0fD03*\n',x,y);
fclose(fileID);
end
end;