How to sort the matrix according to specific row?

3 vues (au cours des 30 derniers jours)
Ash K
Ash K le 8 Déc 2013
Commenté : sixwwwwww le 9 Déc 2013
I have a population generated by pop=[pop;x;y;z;cst,fr]; where first 4 rows are x, second 3 rows are y and third 8 rows are z. cst is sum of column 1 and fr is calculated failure rate of column 2.
6 0.876
5 0.99
3 0.939
6 0.876
4 0.837
7 0.959
4 0.953
4 0.873
0 0
5 0.95
3 0.855
4 0.873
4 0.873
5 0.95
6 0.951
66 0.00032352
6 0.876
6 0.876
6 0.965
6 0.965
4 0.953
4 0.837
4 0.953
0 0
3 0.855
6 0.951
5 0.95
0 0
0 0
3 0.855
6 0.951
59 0.00038143
6 0.965
5 0.888
6 0.965
3 0.863
7 0.889
7 0.959
4 0.953
7 0.915
6 0.968
3 0.855
3 0.855
8 0.942
4 0.873
3 0.855
8 0.942
80 0.0002327
How can I sort the specific (16,32,48) rows followed by unchanged (1:15,17:31,33:47)? for example:
6 0.876
6 0.876
6 0.965
6 0.965
4 0.953
4 0.837
4 0.953
0 0
3 0.855
6 0.951
5 0.95
0 0
0 0
3 0.855
6 0.951
59 0.00038143
6 0.876
5 0.99
3 0.939
6 0.876
4 0.837
7 0.959
4 0.953
4 0.873
0 0
5 0.95
3 0.855
4 0.873
4 0.873
5 0.95
6 0.951
66 0.00032352
6 0.965
5 0.888
6 0.965
3 0.863
7 0.889
7 0.959
4 0.953
7 0.915
6 0.968
3 0.855
3 0.855
8 0.942
4 0.873
3 0.855
8 0.942
80 0.0002327
Please help!

Réponse acceptée

sixwwwwww
sixwwwwww le 8 Déc 2013
Modifié(e) : sixwwwwww le 9 Déc 2013
you can do it as follow:
For example you have your data in variable A then use following line to do it:
A(16:16:end, :) = sortrows(A(16:16:end, :), 1);
I hope it helps. Good luck!
  6 commentaires
Ash K
Ash K le 9 Déc 2013
worked! Thank you sixwwwwwww!
sixwwwwww
sixwwwwww le 9 Déc 2013
you are welcome

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by