how to find max to min of colum value and display with rows

1 回表示 (過去 30 日間)
raqib Iqbal
raqib Iqbal 2020 年 7 月 3 日
コメント済み: madhan ravi 2020 年 7 月 3 日
device=1:20
block=[1 10;2 11;3 7;4 13;5 14]
resource=block(block(:,1) == max(block(:,1)),:)
ROM=[device(1) resource]
o/p== >>>ROM = 1 5 14
what are the syntaes have to use if i want to display max to min of col2 with respective col1 and marged with device number??
and desired output is
1 5 14
2 4 13
3 2 11
4 1 10
5 3 7

回答 (1 件)

madhan ravi
madhan ravi 2020 年 7 月 3 日
ROM = [device(1:size(block,1)).', sortrows(block, 2, 'descend')]
  2 件のコメント
raqib Iqbal
raqib Iqbal 2020 年 7 月 3 日
device=1:20
block=[1 10;2 11;3 7;4 13;5 14]
% resource=block(block(:,1) == max(block(:,1)),:)
% ROM=[[device(1) resource]]
ROM = [device(1:size(block,1)).', sortrows(block, 2, 'descend')]
output---->
Error using sortrows
Too many input arguments.
Error in Code_sumup (line 5)
ROM = [device(1:size(block,1)).', sortrows(block, 2, 'descend')]
sir,this output is showing
madhan ravi
madhan ravi 2020 年 7 月 3 日
>> clear all
device=1:20
block=[1 10;2 11;3 7;4 13;5 14]
ROM = [device(1:size(block,1)).', sortrows(block, 2, 'descend')]
device =
Columns 1 through 3
1 2 3
Columns 4 through 6
4 5 6
Columns 7 through 9
7 8 9
Columns 10 through 12
10 11 12
Columns 13 through 15
13 14 15
Columns 16 through 18
16 17 18
Columns 19 through 20
19 20
block =
1 10
2 11
3 7
4 13
5 14
ROM =
1 5 14
2 4 13
3 2 11
4 1 10
5 3 7

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by