When a is a column vector, returns a maximum value, which is not mentioned here.
When AMXN is a matrix, there are several situations:
①c = Max (max (A)), returns the maximum value of the matrix
②d = max (a,[],1), returns the maximum value of each row, which is the line vector of MX1
③e = max (a,[],2), returns the maximum value of each column, which is the 1XM column vector
④f = max (a,8), filled with 8 when the element is less than 8
⑤[u V] = max (A), returns the row and column number of the largest element of a row
Note the following expressions:
H = max (A)
I = Max (A (:))
J = Max (A (:,:))
The programming experiment is as follows:
A = Fix (rand (5,3) *50)%
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
Result output:
A =
37 47 42
12 27 12
25 8 40
34 8 12
44 12 46
C = 47
D = 44 47 46
E =
47
27
40
34
46
F =
37 47 42
12 27 12
25 6 40
34 7 12
44 12 46
U = 44 47 46
V = 5 1 5
H = 44 47 46
I = 47
J = 44 47 46
Reprint: http://blog.sina.com.cn/s/blog_7da9e4aa0101bumt.html
The usage and meaning of max function in MATLAB