How to arrange ascending order only one column of a matrix?

3 visualizzazioni (ultimi 30 giorni)
Let's say, I have a=[25 10 85 35 71; 1 2 3 4 5] and output shout come b=[10 25 35 71 85; 2 1 4 5 3]

Risposta accettata

Birdman
Birdman il 15 Feb 2018
b=sortrows(a.').'

Più risposte (1)

Andrei Bobrov
Andrei Bobrov il 15 Feb 2018
[~,ii] = sort(a(1,:));
out = a(:,ii);

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by