MATLAB: Can these two for loops be avoided

avoid double for loops

I'm currently stuck with this double for loop. Any way I can avoid this?
points = zeros(1000000,2);
counter = 1;
for i=1:1000
for j=501:1500
points(counter,:) = [i j];
counter = counter + 1;
end
end

Best Answer

n=1000;
m=10;
out=[ reshape(repmat(1:n,m,1),[],1), repmat((1:m)',n,1)]
%or
out=cell2mat(arrayfun(@(x) [ones(m,1)*x (1:m)'],(1:n)','un',0))