MATLAB: How to generate k unique random numbers from 1 to n in matlab 2009 MATLABrandom number generator Hi, I knew randperm(n,k) works but this is after 2011. Can some one tell me if there is any efficient way to do it in matlab 2009. Thanks Best Answer [idx,idx]=sort(rand(1,n));out=idx(1:k) Related SolutionsMATLAB: How to generate dibits using uniform number generator N = 20;dibits = complex(randi([0,1], N, 1), randi([0,1], N, 1)) MATLAB: Unique random number (between 1 and 40) Why not just use randperm()x = randperm(40);If you want to randomly select a subsetK = 10;x = randperm(40,K); Related QuestionHow to sort a vector in a random manner in MATLABUnique commandSampling with periodic replacementGenerating random numbers in orderSelecting unique rows
Best Answer