Home > Archive > Matlab > December 2005 > unrepeated random integers
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
unrepeated random integers
|
|
| bar yolcu 2005-12-17, 7:05 pm |
| Hi all,
I would like to construct a row vector, say 1x5, whose entries are
integers randomly chosen from the interval [1,25].
I know I could use randint command for that, BUT the all the entries
MUST be different. Could you please construct a fast matlab
algorithm for me?
Thank you in advance...
Beginner..
| |
|
| bar yolcu:
<SNIP is looking for unique int randoms...
one of the many solutions
r=randperm(25);
r=r(1:5)
us
| |
|
| bar yolcu:
<SNIP is looking for unique int randoms...
one of the many solutions
[r,r] = sort(rand(1,25));
r = r(1:5)
/PB
|
|
|
|
|