Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Sorting Matrices
Replies: 7   Last Post: Sep 29, 2010 4:33 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 14
Registered: 9/21/10
Re: Sorting Matrices
Posted: Sep 29, 2010 2:44 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Jos (10584) " <#10584@fileexchange.com> wrote in message <i7vo79$onh$1@fred.mathworks.com>...
> "Ian " <ikirby23@yahoo.com> wrote in message
> * snip *

> > Thanks guys very helpfull so far, I can now find all the consectutive numbers from column 1, the problem I have now is it needs to be sorted providing what the max value is of colum 2, for example:
> >
> > A=[ 1030 2520
> > 1031 2375
> > 1315 3618
> > 1317 2694]
> >
> > So for 1030 and 1031 the max value for column 2 is 2520, and for 1315 and 1317 the max value is 3618. I would then want disregard rows 1031 and 1317 and keep 1030 and 1031.

> You have to be a little bit clearer on what you mean by "rows that are consecutive". In my opinion, 1315 and 1317 are NOT consecutive. And you cannot both keep and disregard 1031 (but I assume that is a spelling error ;-) )
> Jos

Hi Jos,

Sorry I have made a couple of mistakes here, I will try to explain this again a bit clearer. In the matrix below, I want to find the maximum value of column 2 for every consecutive number of column 1.

A=[ 1030 2520
1031 2375
1315 3618
1316 2694
1317 2798];

So in the matrix there are two sets of consectutive numbers in column 1, 1st set 1030 & 1031, 2nd set 1315, 1316 & 1317. What I want do is find the max value of column 2 for each set of consecutive numbers, so the maximum value for the first set would be 2520 and the maximum value for the second set would be 3618. I would then want to keep the entire row for the maximum values (1030 & 1315) and bin the rest (1031,1316 & 1317).

I hope this is a little clearer of what I am trying to acheive, this example is only a little snipit of the data set I am workin with, I need something that will work on a data set which has 4000 rows and 2 columns.

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2015. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.