How to sort each row of 120x200 array and keep track of column number ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tural
el 16 de Dic. de 2014
Comentada: Mika
el 18 de Mzo. de 2020
I have 120x200 array , I want to sort each row but I need to keep column number of each entry. so let's sey it is my array :
7 8 2 1
3 9 6 5
5 2 1 9
this should be
1 2 7 8
3 5 6 9
1 2 5 9
and also I need to use old column number of each term ,for example 7 was in column 1 .
How can I do this in matlab (I can do sorting ,but problem is keep track of column numbers)
0 comentarios
Respuesta aceptada
Jos (10584)
el 16 de Dic. de 2014
Use the second output of SORT:
A = [7 8 2 1 ; 3 9 6 5 ; 5 2 1 9]
[Asorted, OrigColIdx] = sort(A,2)
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!