Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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 comentarios

Iniciar sesión para comentar.

Respuesta aceptada

KSSV
KSSV el 15 de Dic. de 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 comentario
Pratik Anandpara
Pratik Anandpara el 15 de Dic. de 2016
Editada: Pratik Anandpara el 15 de Dic. de 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

Iniciar sesión para comentar.

Más respuestas (1)

Jos (10584)
Jos (10584) el 15 de Dic. de 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 comentario
Pratik Anandpara
Pratik Anandpara el 15 de Dic. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by