how to Select a particular column with maximum values?

4 次查看(过去 30 天)
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

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by