times, .*
fi
对象的逐元素乘法
说明
示例
将 fi 对象乘以标量
使用 times
函数执行 fi
对象和标量的逐元素乘法。
a=4; b=fi([2 4 7; 9 0 2])
b = 2 4 7 9 0 2 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 11
a
是双精度标量,而 b
是 fi
对象的矩阵。在 fi
和双精度值之间进行算术运算时,双精度值会转换为具有与 fi
相同的字长和符号性以及最佳精度小数长度的 fi
。该运算的结果是 fi
。
c=a.*b
c = 8 16 28 36 0 8 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 23
在运算过程中,将 a
转换为字长为 16 的 fi
对象。输出 c
是字长为 32 的 fi
对象,它是两个被乘数 a
和 b
的字长之和。这是因为 fimath
中 ProductMode
的默认设置是 FullPrecision
。
将两个 fi 对象相乘
使用 times
函数执行两个 fi
对象的逐元素乘法。
a=fi([5 9 9; 1 2 -3], 1, 16, 3)
a = 5 9 9 1 2 -3 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 3
b=fi([2 4 7; 9 0 2], 1, 16, 3)
b = 2 4 7 9 0 2 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 3
c=a.*b
c = 10 36 63 9 0 -6 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 32 FractionLength: 6
c
的字长和小数长度等于 a
和 b
的字长和小数长度之和。这是因为 fimath
中 ProductMode
的默认设置是 FullPrecision
。
输入参数
A
— 输入数组
标量 | 向量 | 矩阵 | 多维数组
输入数组,指定为由 fi
对象或内置数据类型组成的标量、向量、矩阵或多维数组。输入 A
和 B
的大小必须相同或兼容。有关详细信息,请参阅基本运算的兼容数组大小。
times
不支持数据类型为 boolean
的 fi
对象。
数据类型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
复数支持: 是
B
— 输入数组
标量 | 向量 | 矩阵 | 多维数组
输入数组,指定为由 fi
对象或内置数据类型组成的标量、向量、矩阵或多维数组。输入 A
和 B
的大小必须相同或兼容。有关详细信息,请参阅基本运算的兼容数组大小。
times
不支持数据类型为 boolean
的 fi
对象。
数据类型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fi
复数支持: 是
扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。
使用说明和限制:
任何非
fi
输入必须为常量;也就是说,其值在编译时必须已知,以便将其转换为fi
对象。当您向 MATLAB® Function 模块内的
times
函数提供复数输入时,必须在运行仿真之前将输入声明为复数输入。为此,请转至模型资源管理器,将所有已知复数输入的复/实性参数设置为开。
HDL 代码生成
使用 HDL Coder™ 为 FPGA 和 ASIC 设计生成 VHDL、Verilog 和 SystemVerilog 代码。
版本历史记录
在 R2006a 之前推出R2021b: 隐式扩展更改会影响运算符的参数
从 R2021b 开始增加了 fi
的 times
、plus
和 minus
的隐式扩展,以前返回错误的基本运算的一些参数组合现在能够生成结果。
如果您的代码使用按元素运算符并依赖 MATLAB 以前在出现大小不匹配情况时返回的错误,尤其是在 try/catch
代码块内,则您的代码可能不再捕获这些错误。
有关基本数组运算要求的输入大小的详细信息,请参阅基本运算的兼容数组大小。
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)