how to Select a particular column with maximum values?

1 回表示 (過去 30 日間)
Chetan Fadnis
Chetan Fadnis 2022 年 3 月 16 日
コメント済み: Chetan Fadnis 2022 年 3 月 16 日
I generate a martix of say dimension 10*5; from this matrix I have to select the best column. Final matrix is of order 10*1.
How to generate it? using max it gives a row, not column.

採用された回答

Arif Hoq
Arif Hoq 2022 年 3 月 16 日
try this:
A=randi(100,10,5)
A = 10×5
34 35 20 71 47 96 61 66 73 66 80 43 91 25 50 64 78 80 56 37 55 22 45 68 69 5 85 7 50 57 88 64 16 35 41 77 83 77 34 81 66 32 44 50 75 56 19 42 96 27
output=max(A,[],2)
output = 10×1
71 96 91 80 69 85 88 83 75 96
  6 件のコメント
Arif Hoq
Arif Hoq 2022 年 3 月 16 日
try this:
A=randi(100,10,5)
A = 10×5
23 95 18 65 73 98 76 3 43 92 6 50 6 40 54 42 24 29 76 63 15 36 41 12 27 11 70 9 87 44 13 28 48 83 49 92 62 85 21 50 45 68 76 1 48 47 7 18 50 39
B=vecnorm(A)
B = 1×5
158.5749 182.6855 136.3855 176.0511 179.0782
[M I]=max(B) % index(column no) of maximum value
M = 182.6855
I = 2
output=A(:,I)
output = 10×1
95 76 50 24 36 70 28 62 68 7
Chetan Fadnis
Chetan Fadnis 2022 年 3 月 16 日
Thanks...

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by