Converting from floating point to fixed point.
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
ON
el 27 de Sept. de 2022
Movida: Walter Roberson
el 27 de Sept. de 2022
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 comentarios
Respuesta aceptada
Walter Roberson
el 27 de Sept. de 2022
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 comentario
Walter Roberson
el 27 de Sept. de 2022
Movida: Walter Roberson
el 27 de Sept. de 2022
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)
Más respuestas (1)
Ver también
Categorías
Más información sobre Multirate Signal Processing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!