matlab中矩阵某列最大值,MATLAB怎么取出矩阵每列中最大的数

  • Post author:
  • Post category:其他


你说的列到底是指什么?

a=[2 3;3 6;4 9]是三行两列,

a =

2     3

3     6

4     9

如果你要得到b =

4     9

则程序为

a=[2 3;3 6;4 9]    或者            a=[2 3;3 6;4 9]

b=max(a)                                         b=max(a,[],1)

如果要得到

b =

3

6

9

则程序为:

a=[2 3;3 6;4 9]

b=max(a,[],2)

max具体用法可以见使用help max命令

help max

MAX    Largest component.

For vectors, MAX(X) is the largest element in X. For matrices,

MAX(X) is a row vector containing the maximum element from each

column. For N-D arrays, MAX(X) operates along the first

non-singleton dimension.

[Y,I] = MAX(X) returns the indices of the maximum values in vector I.

If the values along the first non-singleton dimension contain more