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:
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

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