How can i sort a matrix with loops?

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
Sean de Wolski am 19 Nov. 2013

0 Stimmen

x = [1 2 5 4]
For example, t switch the 5 and the 4
x([3 4]) = x([4 3]) %switch linear indices.

Kategorien

Gefragt:

Tom
am 19 Nov. 2013

Beantwortet:

am 19 Nov. 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by