How can I sort a matrix elementwise ?
Mostrar comentarios más antiguos
Hi, I need to sort a matrix elementwise and get the results to a single vector without losing the index of each element.
For example,
A = [3, 4 ; 6, 2]
The sorted vector should be ,
B = [2;3;4;6]
without losing the information of each and every element in the original matrix.
Thank you.
Respuesta aceptada
Más respuestas (1)
Stephan
el 21 de Oct. de 2019
B = sort(reshape(A,[],1))
3 comentarios
Gayan Lankeshwara
el 21 de Oct. de 2019
Stephan
el 21 de Oct. de 2019
[B, idx] = sort(reshape(A,[],1))
[row,col] = ind2sub([size(A,1), size(A,2)],idx)
Gayan Lankeshwara
el 21 de Oct. de 2019
Categorías
Más información sobre Shifting and Sorting Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!