I have an array 'A' of size 50 x 10 filled with doubles.
I want to arrange each row in ascending order to get a new array 'B' but I want to create a third array 'C' where I keep track of the index from original array 'A'
E.g.
Array A (original array):
11 9 13 10
12 4 1 6
13 5 12 12
Array B (rearranged array):
9 10 11 13
1 4 6 12
5 12 12 13
Array C (tracking index from array A):
2 4 1 3
3 2 4 1
2 3 4 1
Thanks
Have you tried sort:
[b, c] = sort(A,2)
The second output of sort is exactly what you want.
[B, C] = sort(A, 2);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With