How can i sort a matrix with loops?
Ältere Kommentare anzeigen
I need to sort each row of a matrix (without sort function) in ascending order using loops and im confused about how i would go about switching values within the row to order them.
Antworten (1)
Sean de Wolski
am 19 Nov. 2013
x = [1 2 5 4]
For example, t switch the 5 and the 4
x([3 4]) = x([4 3]) %switch linear indices.
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!