Decreasing precision while saving data

8 vues (au cours des 30 derniers jours)
Brandon
Brandon le 15 Mai 2012
Greetings -
I am working on a project where I need high precision for the calculations but I do not need the high precision while saving the data for plotting. The data files are currently about 8mbs a piece and I need to save off several hundred of them. I would like to get them smaller. I tried to reduce it to single precision:
data = single(data)
and got the file down to about 2mb each. Is there any way I can further reduce the precision. I only need maybe 4 significant figures.
I am saving the files in .mat format if that is helpful.
Best Regards,

Réponses (1)

Walter Roberson
Walter Roberson le 15 Mai 2012
Do you have an estimate for min() of your data, and max() of your data?
4 significant figures after the decimal point requires 14 bits. Signed would require 1 more. If your value before the decimal point can exceed 1, you would need at least 2 bits for it. This plausibly gets you beyond 16 bits per value. 16 bits per value would allow you to pack 2 values into 32 bits (the space occupied by 1 float), but we could expect that the compressibility of the data would go down (.mat files are usually compressed.) It is not certain that the space would be reduced.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by