MATLAB: Sampling with periodic replacement

fisher-yatesrandperm

I am looking for an efficient way of doing randperm(n,k) many successive times with the same n and k. Can anyone propose something more efficient than the obvious for-loop approach below?
M=1e5;
n=100;
k=10;
A=nan(k,M);
for i=1:M
A(:,i) = randperm(n,k).';
end

Best Answer

In current versions of MATLAB, randperm with small k relative to n (and perhaps other cases) uses a Fisher-Yates shuffle for efficiency.
Older versions of MATLAB use sort(rand) to extract orderings. That can be extended easily:
[~, A] = sort( rand(n, M) );