フィルターのクリア

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 件のコメント
Pratik Anandpara
Pratik Anandpara 2016 年 12 月 15 日
yes...sorry spell mistake it's row
KSSV
KSSV 2016 年 12 月 15 日
It is already answered......

サインインしてコメントする。

採用された回答

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 Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by