MATLAB: How to reduce the storage size required to save a workspace variable on disk

compressionlossyMATLABmatrixreducesavesize;storage

How can I reduce the storage size required to save a workspace variable on disk? I need to save matrices from workspace to my disk and reduce the required storage time. There can be lossy compression.

Best Answer

You can discard some precision using the function "round", and then let the compression of the function, "save", perform the functionality of reduced storage size on disk.
For example, you can observe the file size to be reduced when you save the rounded-off variable to a file as follows:
>> a = rand(100, 'single');
>> b = round(a,3);
>> save singles.mat a
>> save trunc_singles.mat b
The size of the MAT-file "trunc_singles.mat" is smaller than that of the file "singles.mat", however with a loss in precision.