Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
permutation question

Subject: permutation question

From: Wendy

Date: 8 Mar, 2010 20:21:08

Message: 1 of 5

Dear all,

I have a 22215x1 vector, called x_pool. I want to permutate the numbers in this vector. To do that, I generated a order list using

order = randperm(size(x_pool,1));

Then I try to permute the x_pool vector using
B = permute(x_pool,order);

The result, B turns out to be a 18097-D double vector (or matrix). I am not sure how to use B. Is there a way that I can change B into a 22215x1 vector? Is there any other way that I can permute the elements in a vector, except circshift?

Thank you in advance,
Wendy

Subject: permutation question

From: Matt Fig

Date: 8 Mar, 2010 20:40:24

Message: 2 of 5

x_pool(order) is a permutation of x_pool.

Subject: permutation question

From: ade77

Date: 8 Mar, 2010 20:42:09

Message: 3 of 5

"Wendy " <wlq121@gmail.com> wrote in message <hn3m7k$mes$1@fred.mathworks.com>...
> Dear all,
>
> I have a 22215x1 vector, called x_pool. I want to permutate the numbers in this vector. To do that, I generated a order list using
>
> order = randperm(size(x_pool,1));
>
> Then I try to permute the x_pool vector using
> B = permute(x_pool,order);
>
> The result, B turns out to be a 18097-D double vector (or matrix). I am not sure how to use B. Is there a way that I can change B into a 22215x1 vector? Is there any other way that I can permute the elements in a vector, except circshift?
>
> Thank you in advance,
> Wendy

Except I do not understand your question, the function randperm has already done the job for you.

order = randperm(size(x_pool,1));
B = x_pool(order);

Subject: permutation question

From: Matt J

Date: 8 Mar, 2010 20:51:07

Message: 4 of 5

"Wendy " <wlq121@gmail.com> wrote in message <hn3m7k$mes$1@fred.mathworks.com>...
> Dear all,
>
> I have a 22215x1 vector, called x_pool. I want to permutate the numbers in this vector. To do that, I generated a order list using
>
> order = randperm(size(x_pool,1));
>
> Then I try to permute the x_pool vector using
> B = permute(x_pool,order);
===============

You need to read the help for PERMUTE again. The permute function reorders the *dimensions* of x_pool, performing a kind of N-dimensional matrix transpose.
This is not what you want.

Subject: permutation question

From: Wendy

Date: 8 Mar, 2010 20:53:06

Message: 5 of 5

Thank you, all. x_pool(order) works perfectly. To clearify my question,
order = randperm(size(x_pool,1)) generates a list of integers that are the order of permutation, whereas x_pool are actual values.

Thank you,
Wendy

"ade77 " <ade100a@gmail.com> wrote in message <hn3nf1$bgb$1@fred.mathworks.com>...
> "Wendy " <wlq121@gmail.com> wrote in message <hn3m7k$mes$1@fred.mathworks.com>...
> > Dear all,
> >
> > I have a 22215x1 vector, called x_pool. I want to permutate the numbers in this vector. To do that, I generated a order list using
> >
> > order = randperm(size(x_pool,1));
> >
> > Then I try to permute the x_pool vector using
> > B = permute(x_pool,order);
> >
> > The result, B turns out to be a 18097-D double vector (or matrix). I am not sure how to use B. Is there a way that I can change B into a 22215x1 vector? Is there any other way that I can permute the elements in a vector, except circshift?
> >
> > Thank you in advance,
> > Wendy
>
> Except I do not understand your question, the function randperm has already done the job for you.
>
> order = randperm(size(x_pool,1));
> B = x_pool(order);

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us