The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: sorting an array
Replies: 1   Last Post: Feb 2, 2014 3:09 AM

Advanced Search

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

Posts: 14
Registered: 6/10/13
sorting an array
Posted: Feb 2, 2014 2:39 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I have a matrix of size 7 x 2. The first column numbers 1 to 33. It is like this
A=[1 0.743
2 0.734
3 0.843
4 0.694
5 0.274
6 0.458
7 0.358]

Now I want to arrange the second column in descending order and the first column must also move correspondingly. If B is the output
B=[5 0.274
7 0.358
6 0.458
4 0.694
2 0.734
1 0.743
3 0.843].

I can't use the command B=sort(A,2,'descend') as the corresponding first column is wrong. Kindly help me.

Date Subject Author
Read sorting an array
Read Re: sorting an array
Bruno Luong

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.