I need to order a list that is dependant on another list. how to change both lists?

Posted by Ben Fossen on Stack Overflow See other posts from Stack Overflow or by Ben Fossen
Published on 2010-03-25T03:16:04Z Indexed on 2010/03/25 3:23 UTC
Read the original article Hit count: 264

Filed under:
|

I have a Matlab program that generates a list x = 6.1692 8.1863 5.8092 8.2754 6.0891 the program also outputs another list aspl = 680 637 669 599 693.

The two lists are on equal length and the first element in list x is related to the first element in list aspl. I need to graph the two lists but want list aspl to be in order from smallest to largest. How would I go about doing this? If I need to move the first element in aspl to position 4 in the list, then the first element of list x also needs to be moved to position 4 in list x. The numbers above are not important they are just examples, the actual program generates hundereds of numbers.

for example x = 6.1692 8.1863 5.8092 8.2754 initially

     aspl =  680   637   669   599   693

after changing aspl to ascending order this is how x should look.

x = 5.8092 8.1863 5.8092 6.1692 8.2754

aspl = 599 637 669 680 693

© Stack Overflow or respective owner

Related posts about matlab

Related posts about lists