max函数(matlab)

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.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值