max函数(matlab)
1. C = max(A):
如果A是一个向量,那么C便是这个向量元素中的最大值;
2. C=max(A,[ ],1) //返回矩阵的每一列最大值
如果A是一个二维矩阵,等同于C=max(A,[ ],1) ,那么C便是选出每一列中的最大值,返回一个1*n的矩阵,或者说是一个n维行向量。
3. C=max(A,[ ],2) //返回矩阵的每一行最大值
4. C=max(max(A));
A是一个矩阵,返回值C就是这个矩阵的最大值。
如下为MATlab帮助文档内容;
max
Largest elements in array
Syntax
C = max(A)
C = max(A,B)
C = max(A,[],dim)
[C,I] = max(...)
Description
C = max(A) returns thelargest elements along different dimensions of an array.
If A is a vector, max(A) returnsthe largest element in A.
If A is a matrix, max(A) treatsthe columns of A as vectors, returning a row vectorcontaining the maximum element from each column.
If A is a multidimensional array, max(A) treatsthe values along the first non-singleton dimension as vectors, returningthe maximum value of each vector.
C = max(A,B) returns anarray the same size asA and B withthe largest elements taken from A or B.The dimensions ofA and B mustmatch, or they may be scalar.
C = max(A,[],dim) returnsthe largest elements along the dimension ofA specifiedby scalar dim. For example, max(A,[],1) producesthe maximum values along the first dimension ofA.
[C,I] = max(...) findsthe indices of the maximum values ofA, and returnsthem in output vector I. If there are several identicalmaximum values, the index of the first one found is returned.
Examples
Return the maximum of a 2-by-3 matrix from each column:
X = [2 8 4; 7 3 9]; max(X,[],1) ans = 7 8 9
Return the maximumfrom each row:
max(X,[],2) ans = 8 9
Compare each element of X toa scalar:
max(X,5) ans = 5 8 5 7 5 9
Remarks
For complex input A, max returnsthe complex number with the largest complex modulus (magnitude), computedwithmax(abs(A)). Then computes the largest phaseangle with max(angle(x)), if necessary.
The max function ignores NaNs.