help with max function

조회 수: 2 (최근 30일)
Marco Nashaat
Marco Nashaat 2020년 2월 10일
댓글: the cyclist 2020년 10월 29일
[Max,index]=max(array,[ ],2)..... Iam using this syntax to find the maximum value of every column but in case of two equal maximum values it returns the first one... how can I solve this?! Thanks
  댓글 수: 5
Mohymen Kushal
Mohymen Kushal 2020년 10월 26일
if A is a matrix, then max(A,[ ],2) is a column vector containing the maximum value of each row . What is this '2' for ? can anybody explain please. Thanks.
the cyclist
the cyclist 2020년 10월 29일
As clearly stated in the documentation for max, that "2" indicates the matrix dimension along which to take the maximum.

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

채택된 답변

the cyclist
the cyclist 2020년 2월 10일
This code will return the row and column indices where the entry is equal to the column's maximum.
[rowIdx,colIdx] = find(A==max(A))

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by