Converting double values file to 2 byte per sample.
Mostrar comentarios más antiguos
Hi,
I have a .txt file with 128 x 11900 vlaues. These values are doubles ranging from -0.00023462 to +1.0719. I need to convert them to 2 bytes per sample and store in a .bin file. I am not getting how to do it. I tried using the 'fread' function of matlab but all I am able to do is convert each sample to 8 bytes(double precision). Is there a way I can convert each sample into 2 bytes each?
Respuesta aceptada
Más respuestas (1)
James Tursa
el 16 de Jul. de 2020
0 votos
If you want a two byte floating point representation you can use half precision. E.g.,
This is one of the standard floating point formats, but will result in less precision than Walter's method because some of the bits are used for sign and exponent.
Categorías
Más información sobre Numeric Types en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!