matlab - i have 40401 by 57 matrix I need find max value from each row and the corresponding column index of that max value? -
i have 40401 57 matrix need find max value each row , corresponding column index of max value?
some 1 please me find answer..
just looking in documentation can find syntax of max
find maximum of a
on given dimension dim
. there example here.
m = max(a,[],dim)
note second argument empty matrix []
because don't want calculate maximum of entries in a
, second argument. feature of max
has no relevance here.
now need indexes. looking again in documentation find syntax maximum values m
, indexes i
@ same time. there example here well.
[m,i] = max(___)
note here ___
means syntax not depend on input values.
now can combine following line of code:
[m,i] = max(a,[],2)
this result when used random data:
a = 2 20 6 8 5 13 16 11 10 2 10 20 9 11 14 6 19 5 15 2 17 19 1 11 m = 20 20 19 19 = 2 6 5 4
Comments
Post a Comment