Fastest solution to list all pairs of n integers?

旧巷老猫 提交于 2019-11-29 15:45:43

To replace nchoosek(1:N,2)

With bsxfun -

[Y,X] = find(bsxfun(@gt,[1:N]',[1:N]))
pair = [X, Y];

With tril and find only (without ind2sub) -

[y,x] = find(tril(true(N),-1))
pair = [X, Y];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!