I want to list all possible pairs of the integers [1, n] with a large n. I find myself looking for the fastest option. This is what I\'ve come up w
[1, n]
n
To replace nchoosek(1:N,2)
nchoosek(1:N,2)
With bsxfun -
bsxfun
[Y,X] = find(bsxfun(@gt,[1:N]',[1:N])) pair = [X, Y];
With tril and find only (without ind2sub) -
tril
find
ind2sub
[y,x] = find(tril(true(N),-1)) pair = [X, Y];