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

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by