How to ranking the values of one column in matrix and replace it without sorting of values of next column?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Beibit Sautbek
am 20 Jul. 2016
Bearbeitet: Azzi Abdelmalek
am 20 Jul. 2016
I have 4 points with x and y values: [4,7],[2,2],[10,2],[6,1].
And I put all points in one matrix A, where the first column represents x values, the second column shows y values of 4 points.
A =
4 7
2 2
10 2
6 1
I need to rank x values by putting in first row the lowest x=2, the second row x=4 and so on. But I don't
need to sort the second column (y values should be replaced with x values):
I need a result as shown below in matrix A:
A =
2 2
4 7
6 1
10 2
So, the lowest x values represents the first point,
For clearance:
1 point=[2,2]
2 point=[4,7]
3 point=[6,1]
4 point=[10,2]
Could anyone help me?
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 20 Jul. 2016
Bearbeitet: Azzi Abdelmalek
am 20 Jul. 2016
A =[ 4 7
2 2
10 2
6 1]
B=sortrows(A)
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!