|
"Jan Simon" <matlab.THIS_YEAR@nMINUSsimon.de> wrote in message <i1428g$q8d$1@fred.mathworks.com>...
> Dear Ulrik,
>
> > Suppose I wish to draw 2 numbers at random without replacement from vector A
> > A = [1 2 3 4 5 6 7 8 9 10]
> > Which command will let me do this in Matlab?
>
> See RANDPERM: Permute the vector randomly and draw the first 2 numbers.
>
> If you need speed, see:
> http://www.mathworks.com/matlabcentral/fileexchange/27076
> If your A is large, e.g. 1e7 elements, the random permutation wastes a remarkable chunk of time and memory. SHUFFLE in the "index" mode is more efficient:
> A = rand(1, 1e7);
> Index = Shuffle(1e7, 'index', 2);
> B = A(Index)
>
> Good luck, Jan
Thanks Jan, that was a great help.
|