Matlab中max函数在矩阵中求函数大小的实例如下:

C = max(A)
返回一个数组各不同维中的最大元素。
如果A是一个向量,max(A)返回A中的最大元素。
如果A是一个矩阵,max(A)将A的每一列作为一个向量,返回一行向量包含了每一列的最大元素。
如果A是多为数组,max(A) treats the values along the first non-singleton dimension as vectors, returning the maximum value of each vector.

C = max(A,B)
返回一个和A和B同大小的数组,其中的元素是从A或B中取出的最大元素。

C = max(A,[],dim)
返回A中有dim指定的维数范围中的最大值。

[C,I] = max(...)
找到A中那些最大值的索引位置,将他们放在向量I中返回。如果这里有多个相同最大值时,返回的将是第一个的索引。

详细举例:

细说MATLAB中的MAX函数 
一:MAX函数的几种形式 
(1)max(a) (2)max(a,b) (3)max(a,[],dim) (4)[C,I]=max(a) (5)[C,I]=max(a,[],dim) 
二:举例说明函数意思 
(1)max(a) 
如果a是一个矩阵,比如a=[1,2,3;4,5,6],max(a)的意思就是找出矩阵每列的最大值, 本例中:max(a)=[4,5,6] 
(2)max(a,b) 
如果a和b都是大于1维的矩阵,那么要求a和b的行列的维数都要相等,函数的结果是比较a和b中每个元素的大小,比如: 
a=[1,2,3;4,5,6]      b=[4,5,6;7,8,3] max(a,b)=[4,5,6;7,8,6]

另外,如果a和b中至少有一个是常数,也是可以的。

比如: a=[1,2,3;4,5,6]         b=3        c=5 
          max(a,b)=[3,3,3;4,5,6]

max(b,c)=5

相信大家看了例子都明白了函数的意思了吧       
(3)max(a,[],dim) 
这个函数的意思是针对于2维矩阵的,dim是英文字母dimension的缩写,意思是维数。 当dim=1时,比较的a矩阵的行,也就是和max(a)的效果是一样的;当dim2时,比较的是a矩阵的行。下面举个例子: 
a=[1,2,3;4,5,6]       max(a)=max(a,[],1)=[4,5,6]    比较的第一行和第二行的值                    max(a,[],2)=[3,6]

(4)[C,I]=max(a) 
C表示的是矩阵a每列的最大值,I表示的是每个最大值对应的下标: 下面举例说明: 
还是刚才那个例子:a=[1,2,3;4,5,6]          [C,I]=max(a) 
结果显示的是C=[4,5,6]       I=[2,2,2]   返回的是最大值对应的行号。 
(5)[C,I]=max(a,[],dim) 
同理:如果dim=1时,其结果和[c,i]=max(a)是一样的。 当dim=2时,同样上面的矩阵a,我们运行一下: 
[c,i]=max(a,[],2)     结果是:c=[3,6]   i=[3,3]    i返回的是矩阵a的列号。

----------------------------------------------
max

Maximum elements of an array

Syntax

C = max(A)
C = max(A,B)
C = max(A,[],dim)
[C,I] = max(...)

Description

C = max(A) returns the largest elements along different dimensions of an array. If A is a vector, max(A) returns the largest element in A. If A is a matrix, max(A) treats the columns of A as vectors, returning a row vector containing the maximum element from each column. If A is a multidimensional array, max(A) treats the values along the first non-singleton dimension as vectors, returning the maximum value of each vector.

C = max(A,B) returns an array the same size as A and B with the largest elements taken from A or B.

C = max(A,[],dim) returns the largest elements along the dimension of A specified by scalar dim. For example, max(A,[],1) produces the maximum values along the first dimension (the rows) of A.

[C,I] = max(...) finds the indices of the maximum values of A, and returns them in output vector I. If there are several identical maximum values, the index of the first one found is returned.

Remarks

For complex input A, max returns the complex number with the largest complex modulus (magnitude), computed with max(abs(A)), and ignores the phase angle, angle(A). The max function ignores NaNs.

See Also

isnan, mean, median, min, sort

Matlab:max函数的更多相关文章

  1. matlab max函数

    >> a=[1,6,3;7,5,6] a = 1 6 3 7 5 6 >> [q,p]=max(a,[],2) 返回每行最大值,q是结果.p是索引 q = 6 7 p = 2 ...

  2. matlab 中max函数用法

    Matlab中max函数在矩阵中求函数大小的实例如下:(1)C = max(A)返回一个数组各不同维中的最大元素.如果A是一个向量,max(A)返回A中的最大元素.如果A是一个矩阵,max(A)将A的 ...

  3. Matlab中函数定义方法

    Matlab自定义函数的六种方法 n1.函数文件+调用函数(命令)文件:需单独定义一个自定义函数的M文件: n2.函数文件+子函数:定义一个具有多个自定义函数的M文件: n3.Inline:无需M文件 ...

  4. Matlab图像处理函数:regionprops

    本篇文章为转载,仅为方便学术讨论所用,不用于商业用途.由于时间较久,原作者以及原始链接暂时无法找到,如有侵权以及其他任何事宜欢迎跟我联系,如有侵扰,在此提前表示歉意.----------------- ...

  5. matlab 常用函数

    Matlab常用函数 Matlab的内部常数  eps   浮点相对精度  pi  圆周率  exp  自然对数的底数e  i 或j  虚数单位  Inf或 inf  无穷大 Matlab概率密度函数 ...

  6. matlab——sparse函数和full函数

    转载:http://www.cnblogs.com/lihuidashen/p/3435883.html matlab——sparse函数和full函数(稀疏矩阵和非稀疏矩阵转换)   函数功能:生成 ...

  7. matlab 常用函数(数学建模-复习)

    常用函数 fscanf(fid, '%c', inf) -> 直接读取整个文件, 因为inf表示无穷 strtrim char(num): 将num转为ASCII字符 strtok(conten ...

  8. MATLAB自定义函数

    MATLAB自定义函数形式 function [a,b,c] = funname(x1,x2,x3) 输入变量 对于输入变量,MATLAB可以识别输入变量的个数,通过nargin来记录当前输入变量个数 ...

  9. JS Math.max() 函数

    Math.max(a,b,...,x,y) -- 返回数个数字中较大的值 max是maximum的缩写,中文"最大量"的意思 max函数语法Math.max(a,b,...,x,y ...

随机推荐

  1. 在linux上使用"scp"命令拷贝一个目录到另一台服务器的时候报"not a regular file"错误的解决办法

    今天在linux命令行使用scp命令拷贝一个目录到另一台服务器的时候,报如下错误: [root@hadoop01 ~]# scp flume -r hadoop02:/root/apps flume: ...

  2. Linux远程管理

    若想要远程管理服务器,对于Windows系统,应该比较容易理解,通过window系统自带的远程桌面客户端即可登录远程服务器,从而实现在本地对远程服务器的管理.然而对于linux服务器来说这种方法就不行 ...

  3. SAP中寄售处理

    寄售分两种: 1, 供应商提供货物,我们销售 2,我们提供货物,寄售商销售 [@more@] 1, 供应商提供货物,我们销售 创建PO,购买寄售货物,categories维护成K,然后收货即可. 2, ...

  4. Bash脚本15分钟进阶教程

    转载: Bash脚本15分钟进阶教程 这里的技术技巧最初是来自谷歌的"Testing on the Toilet" (TOTT).这里是一个修订和扩增版本. 脚本安全 我的所有ba ...

  5. eclipse导入git项目(转)

    1.首先在github.com上申请一个账号2.Eclipse需要安装egit插件,在Eclipse中选择help->Marketplace,在search中输入egit,找到后安装即可 3.从 ...

  6. HTML5自学笔记[ 24 ]canvas绘图之星空草地

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. 如何设置一个严格30分钟过期的Session

    今天在我的微博(Laruence)上发出一个问题: 我在面试的时候, 经常会问一个问题: “如何设置一个30分钟过期的Session?”, 大家不要觉得看似简单, 这里面包含的知识挺多, 特别适合考察 ...

  8. Linux Bash代码 利用for循环实现命令的多次执行

    Linux Bash代码 [yuanhao15@lu01 libsvm-rank-2.81]$ for ((i=0; i<=19; i++)) do ./svm-train -s 5 -c 10 ...

  9. 语句--分支语句if case

    语句是指程序命令,都是按照顺序执行的.语句在程序中的执行顺序称为“控制流”或者“执行流”.根据程序对运行时所收到的输入的响应,在程序每次运行时控制流可能有所不同. 语句可以嵌套,可以是以分号结尾的单行 ...

  10. BZOJ2280 [Poi2011]Plot

    恩..这题真是sxbk 我们先二分答案,然后判断答案是否满足要求 判断方法是二分当前段的长度一直做到底,当然我们可以用倍增这样快一点,直接随机增量就可以了 然后就是卡常..... 然后就是卡精度QAQ ...