max
fi 对象数组中的最大元素
说明
示例
创建一个定点向量,并返回向量的最大值。
A = fi([1,5,4,9,2],1,16); M = max(A)
M =
9
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 11
创建一个定点矩阵。
A = fi(magic(4),1,16)
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 10
通过沿第二个维度查找最大值来查找每一行的最大元素。
M = max(A,[],2)
M =
16
11
12
15
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 10
输出向量 M 是一个列向量,包含了每一行的最大元素。
创建一个定点矩阵。
A = fi(magic(4),1,16)
A =
16 2 3 13
5 11 10 8
9 7 6 12
4 14 15 1
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 10
查找每一列的最大元素。
M = max(A)
M =
16 14 15 13
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 10
输出 M 是一个行向量,包含了 A 中每一列的最大元素。
查找每个最大元素的索引。
[M,I] = max(A)
M =
16 14 15 13
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 10
I = 1×4
1 4 4 1
向量 I 包含 M 中最小元素的索引。
创建两个相同大小的定点数组。
A = fi([2.3,4.7,6;0,7,9.23],1,16); B = fi([9.8,3.21,1.6;pi,2.3,1],1,16);
从 A 或 B 中查找最大元素。
C = max(A,B)
C =
9.7998 4.7002 6.0000
3.1416 7.0000 9.2300
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 11
C 包含 A 和 B 中每对对应元素中的最大元素。
创建一个复数定点向量 a。
a = fi([1+2i,3+6i,6+3i,2-4i],1,16)
a =
1.0000 + 2.0000i 3.0000 + 6.0000i 6.0000 + 3.0000i 2.0000 - 4.0000i
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 12
该函数通过提取具有最大幅值的元素查找复数向量的最大元素。
abs(a)
ans =
2.2361 6.7083 6.7083 4.4722
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 12
在向量 a 中,位置 2 和 3 处的最大元素的幅值为 6.7083。max 函数返回输出 x 中的最大元素以及该元素在输出 y 中的索引。
[x,y] = max(a)
x =
3.0000 + 6.0000i
DataTypeMode: Fixed-point: binary point scaling
Signedness: Signed
WordLength: 16
FractionLength: 12
y = 2
尽管索引 2 和 3 处的元素具有相同的幅值,但始终返回该值第一次出现位置的索引。
输入参数
其他输入 fi 或数值数组,指定为标量、向量、矩阵或多维数组。A 和 B 的维度必须匹配,除非其中一个是标量。
max 函数忽略 NaNs。
数据类型:fi|single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
复数支持:是
运算维度,指定为正整数标量。dim 也可以是 fi 对象。如果不指定值,则默认值是大小不等于 1 的第一个数组维度。
数据类型:fi|single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
输出参量
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
HDL 代码生成
使用 HDL Coder™ 为 FPGA 和 ASIC 设计生成 VHDL、Verilog 和 SystemVerilog 代码。
版本历史记录
在 R2006a 之前推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)