Converting from floating point to fixed point.
12 次查看(过去 30 天)
显示 更早的评论
How can i convert from floating point to two's complement? I need to convert a vector of filter coefficients from Filter Designer but I do not know how.
0 个评论
采纳的回答
Walter Roberson
2022-9-27
The Fixed Point Toolbox fi() can be used to create a variety of fixed point formats.
If you need to match a particular hardware fixed point format for a dsp then we would need to know the details of the representation.
1 个评论
Walter Roberson
2022-9-27
移动:Walter Roberson
2022-9-27
format long g
BitsAfterDecimalPoint = 12;
Value = -0.0126842654631061924064283630286809057
encoded = int16(Value * 2^BitsAfterDecimalPoint)
decoded = double(encoded) / 2^BitsAfterDecimalPoint
abs(Value - decoded)
There is a limit to how much precision you can get with 16 bits...
BitsAfterDecimalPoint = 16;
encoded = int16(Value * 2^BitsAfterDecimalPoint)
decoded = double(encoded) / 2^BitsAfterDecimalPoint
abs(Value - decoded)
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!