Thread Subject: vectorization problem part II

Subject: vectorization problem part II

From: Nick Valensi

Date: 21 Nov, 2009 15:03:03

Message: 1 of 5

I've another problem that seems so simple but i can't figure it out. Well i can, but not in a fast way. I still have this matrix for example:

5 1
5 3
5 2
6 2.5
6 2.1
6 2.9
7 8
7 9
7 1

this matrix is ordered based on the first row. For all similar values in this first row i also want to order the values in de second row. So then you get this:

5 1
5 2
5 3
6 2.1
6 2.5
6 2.9
7 1
7 8
7 9

Looks so simple, i tried that with a combination of accumarray and sortrows..that didn't work though. Any smart people here that can help me? No more questions after this one..well maybe 1 :)

-NV-

Subject: vectorization problem part II

From: Bruno Luong

Date: 21 Nov, 2009 15:55:07

Message: 2 of 5

>> a=[5 1
5 3
5 2
6 2.5
6 2.1
6 2.9
7 8
7 9
7 1];

>> sortrows(a)

ans =

    5.0000 1.0000
    5.0000 2.0000
    5.0000 3.0000
    6.0000 2.1000
    6.0000 2.5000
    6.0000 2.9000
    7.0000 1.0000
    7.0000 8.0000
    7.0000 9.0000

Seems working fine to me

Bruno

Subject: vectorization problem part II

From: Nick Valensi

Date: 21 Nov, 2009 16:11:05

Message: 3 of 5

Ok, in fact that did work. I just made my example a bit too simple. But after rearranging some collumns i figured it out.

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <he92gq$bqh$1@fred.mathworks.com>...
> >> a=[5 1
> 5 3
> 5 2
> 6 2.5
> 6 2.1
> 6 2.9
> 7 8
> 7 9
> 7 1];
>
> >> sortrows(a)
>
> ans =
>
> 5.0000 1.0000
> 5.0000 2.0000
> 5.0000 3.0000
> 6.0000 2.1000
> 6.0000 2.5000
> 6.0000 2.9000
> 7.0000 1.0000
> 7.0000 8.0000
> 7.0000 9.0000
>
> Seems working fine to me
>
> Bruno

Subject: vectorization problem part II

From: Nick Valensi

Date: 21 Nov, 2009 18:11:06

Message: 4 of 5

The problem was more that the collumns i want to sort are not the first two collumns, but like the 4th en 11 th collumn. I know rearranged the collumns but i bet it's possible in another way as well.

"Nick Valensi" <G.vaneck@student.tudelft.nl> wrote in message <he93ep$91d$1@fred.mathworks.com>...
> Ok, in fact that did work. I just made my example a bit too simple. But after rearranging some collumns i figured it out.
>
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <he92gq$bqh$1@fred.mathworks.com>...
> > >> a=[5 1
> > 5 3
> > 5 2
> > 6 2.5
> > 6 2.1
> > 6 2.9
> > 7 8
> > 7 9
> > 7 1];
> >
> > >> sortrows(a)
> >
> > ans =
> >
> > 5.0000 1.0000
> > 5.0000 2.0000
> > 5.0000 3.0000
> > 6.0000 2.1000
> > 6.0000 2.5000
> > 6.0000 2.9000
> > 7.0000 1.0000
> > 7.0000 8.0000
> > 7.0000 9.0000
> >
> > Seems working fine to me
> >
> > Bruno

Subject: vectorization problem part II

From: Bruno Luong

Date: 21 Nov, 2009 19:23:03

Message: 5 of 5

"Nick Valensi" <G.vaneck@student.tudelft.nl> wrote in message <he9afq$fmp$1@fred.mathworks.com>...
> The problem was more that the collumns i want to sort are not the first two collumns, but like the 4th en 11 th collumn. I know rearranged the collumns but i bet it's possible in another way as well.

Well, you should read more carefully the help of sortrows, especially the second input.

Bruno

Tags for this Thread

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com