Thread Subject:
How to sort a 2-d matrix

Subject: How to sort a 2-d matrix

From: bakero

Date: 4 May, 2010 10:48:28

Message: 1 of 2

Hi everyone

I'd like to know if there is any instruction in matlab to sort a matrix like this example:

X =[ 0.506 0.258 0.478
     201 203 202]

x_sorted = [0.258 0.478 0.506
            203 202 201]

What I am looking for is to sort the first row in ascend way and moving the value on the second row which belongs to each first row index. For instance, if 0.506 is the maximum value on first row, put it into the last place and moving 201 with it.

I don't know whether this is possible or not.

Does anyone know how to do it?

Many thanks in advance

Regards.

Subject: How to sort a 2-d matrix

From: Sean

Date: 4 May, 2010 12:39:04

Message: 2 of 2

bakero <morien3@gmail.com> wrote in message <157383103.68823.1272970138577.JavaMail.root@gallium.mathforum.org>...
> Hi everyone
>
> I'd like to know if there is any instruction in matlab to sort a matrix like this example:
>
> X =[ 0.506 0.258 0.478
> 201 203 202]
>
> x_sorted = [0.258 0.478 0.506
> 203 202 201]
>
> What I am looking for is to sort the first row in ascend way and moving the value on the second row which belongs to each first row index. For instance, if 0.506 is the maximum value on first row, put it into the last place and moving 201 with it.
>
> I don't know whether this is possible or not.
>
> Does anyone know how to do it?
>
> Many thanks in advance
>
> Regards.

>>help sortrows

Good Luck!

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
reference Sean de 4 May, 2010 08:44:07
sortrows Sean de 4 May, 2010 08:44:07
rssFeed for this Thread

Contact us