Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commenti

Accedi per commentare.

Risposta accettata

KSSV
KSSV il 15 Dic 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 Commento
Pratik Anandpara
Pratik Anandpara il 15 Dic 2016
Modificato: Pratik Anandpara il 15 Dic 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

Accedi per commentare.

Più risposte (1)

Jos (10584)
Jos (10584) il 15 Dic 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 Commento
Pratik Anandpara
Pratik Anandpara il 15 Dic 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

Accedi per commentare.

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by