C = max (A)
Returns the largest element in a different dimension of an array.
If a is a vector, Max (a) returns the largest element in a.
If A is a matrix, Max (a) takes each column of a as a vector, and returns a row of vectors containing the largest element of each column.
C = Max (A, B)
Returns an array of the same size as a and B, where the element is the largest element taken out of a or B.
When AMXN is a matrix, there are several situations:
A = Fix (rand (5,3) *50)% generates 5x3 random matrix
B = a;% Matrix backup once
C = Max (max (A))% matrix maximum
D = max (a,[],1)% of the maximum value of each column to get the row vector
E = max (a,[],2)% of the maximum value of each row, get the column vector
F = max (a,8)% less than 8 is replaced with 8
[U V] = max (A)%u is the column extremum and V is the line number
H = max (A)% function with D
I = Max (A (:))% function with C
J = Max (A (:,:))% function with D
[C,i]=max (a,[],1)% function is the same as [U V] = max (A)
[C,i]=max (a,[],2)%%c for row and column extremum, I number
A = fix (rand (5,3) *50)% generates random 5x3 matrix B = a;% Matrix backup once C = Max (max (A))% Matrix maximum d = max (a,[],1)% per column maximum, get row vector e = max (a,[],2)% per row, get column vector F = max (a,8)% less than 8 is replaced with 8[u V] = max (a)%u is the column extremum, V is line number h = max (a)% function with DI = max (A (:))% function with CJ = MAX (A (:,:))% function with D [C,i]=max (a,[],1)% function Same as [U V] = max (A) [C,i]=max (a,[],2)%%c is a row and column extremum, i row number A = 5 6 5 6 4 25C = 43D = 6 ( 43) 25F = 8 8 8 8 24 8 25U = 35V = 1 4 3H = A. 35I = 43J = 41 35c = 35i = 1 4 3c = 6 + 25i = 1 1 1) 2 3
Usage of max in MATLAB