Reply by "Sameer S.M" May 29, 20072007-05-29
Hi Emre,

I think u can use the built in function, "randperm" or "permute". Have a
look at the help for these commands..

bye
sameer

On 5/27/07, Emre ARDALI wrote:
>
> Hi everybody;
> I want to learn about if it is possible rearrange a vector in MATLAB in a
> random manner. For example i have the vector=[1 3 5 8 7 0] and i want a new
> vector using the vector elements but different order
> i.e. new_vector=[0 7 3 1 8 5 ]; this order sould be random.
> Any idea?
>
> I think to use "randint" to regenerate indexes then create new vector
> using new index order. But problem is such a random indexing may repeated.
> Some index may appear more than 1 times and some does not appear.
>
> Do you have any advise?
>
> Thanks
> Regards
>
> Emre
>
Reply by sjoh...@cnbc.cmu.edu May 29, 20072007-05-29
Emre,
You can use the randperm function for doing this. RANDPERM(n) is a
random permutation of the integers from 1 to n. So, if you have a vector
,V , get random index vector of V, by assigning,

z = randperm(size(V,2));
new_V = V(z);

So, if V = [1 3 5 8 7 0];
then z= randperm(V) could be [6 5 2 1 4 3], and therefore,
V(z) will be [0 7 3 1 8 5 ];

Remember to repeat both the steps above to generate new random arrangement
everytime. Let me know if this makes sense.
> Hi everybody;
> I want to learn about if it is possible rearrange a vector in MATLAB in a
> random manner. For example i have the vector=[1 3 5 8 7 0] and i want a
> new vector using the vector elements but different order
> i.e. new_vector=[0 7 3 1 8 5 ]; this order sould be random.
> Any idea?
>
> I think to use "randint" to regenerate indexes then create new vector
> using new index order. But problem is such a random indexing may repeated.
> Some index may appear more than 1 times and some does not appear.
>
> Do you have any advise?
>
> Thanks
> Regards
>
> Emre
>
Reply by Emre ARDALI May 28, 20072007-05-28
Hi everybody;
I want to learn about if it is possible rearrange a vector in MATLAB in a random manner. For example i have the vector=[1 3 5 8 7 0] and i want a new vector using the vector elements but different order
i.e. new_vector=[0 7 3 1 8 5 ]; this order sould be random.
Any idea?

I think to use "randint" to regenerate indexes then create new vector using new index order. But problem is such a random indexing may repeated. Some index may appear more than 1 times and some does not appear.

Do you have any advise?

Thanks
Regards

Emre