필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
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

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2016년 12월 15일
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
Pratik Anandpara
Pratik Anandpara 2016년 12월 15일
편집: Pratik Anandpara 2016년 12월 15일
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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jos (10584)
Jos (10584) 2016년 12월 15일
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
Pratik Anandpara
Pratik Anandpara 2016년 12월 15일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by