Effacer les filtres
Effacer les filtres

random matrix 6*3 and i want set row according highest total of row set as first than lower

1 vue (au cours des 30 derniers jours)
2.00 1.00 6.00 =9
0 8.00 2.00 =10
1.00 2.00 1.00 =4
5.00 0 8.00=13
6.00 0 5.00=11
3.00 0 6.00=9
now rearrange and set matrix is
5.00 0.00 8.00
6.00 0.00 5.00
0.00 8.00 2.00
2.00 1.00 6.00
3.00 0 6.00
1.00 2.00 1.00
this row order is not fix each time 6*3 random matrix but raw order high is set as first
  3 commentaires

Connectez-vous pour commenter.

Réponse acceptée

KSSV
KSSV le 15 Déc 2016
A = [2.00 1.00 6.00
0 8.00 2.00
1.00 2.00 1.00
5.00 0 8.00
6.00 0 5.00
3.00 0 6.00];
thesum = sum(A,2) ;
[val,idx] = sort(thesum,'descend') ;
B = A(idx,:)
  1 commentaire
Pratik Anandpara
Pratik Anandpara le 15 Déc 2016
Modifié(e) : Pratik Anandpara le 15 Déc 2016
https://in.mathworks.com/matlabcentral/answers/317002-i-generate-three-digit-from-crossover-with-another-digit-but-now-i-valid-only-that-child1-child2-chi
help for this

Connectez-vous pour commenter.

Plus de réponses (1)

Jos (10584)
Jos (10584) le 15 Déc 2016
Let A be your matrix of values:
rowsumA = sum(A,2) % sum over rows
[~,ix] = sort(rowsumA, 'descend') % sort these sums in descending order
B = A(ix,:) sort the matrix A accordingly
  1 commentaire
Pratik Anandpara
Pratik Anandpara le 15 Déc 2016
https://in.mathworks.com/matlabcentral/answers/317002-i-generate-three-digit-from-crossover-with-another-digit-but-now-i-valid-only-that-child1-child2-chi
help

Connectez-vous pour commenter.

Catégories

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

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by