Possible Duplicate:
32 bit hex to 32 bit floating point (IEEE 754) conversion in matlab
我正在尝试测试用 VHDL 编写的过滤器的功能,该过滤器的输入是单精度 float 。为此,我想在 MATLAB 中将表示正弦波的实数数组转换为 float 的十六进制表示形式的数组。将此数组应用于过滤器并将输出转换为实际值。
即我需要一个函数来执行以下 -3.48 = 0x"C05EB851"
,该函数在 this site 上执行并且它是相反的。
有人有执行此操作的 MATLAB 函数/m 文件吗?非常感谢任何帮助
干杯
>> help num2hex
NUM2HEX Convert singles and doubles to IEEE hexadecimal strings.
If X is a single or double precision array with n elements,
NUM2HEX(X) is an n-by-8 or n-by-16 char array of the hexadecimal
floating point representation. The same representation is printed
with FORMAT HEX.
让我们试试你的例子:
>> num2hex(single(-3.48))
ans =
c05eb852
足够接近了吗?