DSPRelated.com
Forums

How do I compress an array of floating numbers in Matlab?

Started by Luna Moon April 2, 2010
On Apr 5, 5:29&#4294967295;pm, "Jan Simon" <matlab.THIS_Y...@nMINUSsimon.de>
wrote:
> Dear Luna! > > > I have a vector of real numbers in Matlab. How do I compress them? &#4294967295;Of > > course this has to be lossless, since I need to be able to recover > > them. > > > The goal is to study the Shannon rate and entropy of these real > > numbers, so I decide to compress them and see how much compression > > ratio I can have. > > > I don't need to write the result into compressed files, so those > > headers, etc. are just overhead for me which affect me calculating the > > Entropy... so I just need a bare version of the compress ratio... > > Michael Kleder's function compresses data in the memory with the zlib: > &#4294967295;http://www.mathworks.com/matlabcentral/fileexchange/8899 > > E.g. for sin(1:1e5) this saves 5% memory. 7-zip reduces the file by at least 25%. > > Good luck, Jan
So how is this approach: I first write the floating numbers to a TEXT file, and then call Winzip or 7Zip from within Matlab and then measure the file size change before and after the compression, and then compute the ratio.
On Apr 5, 7:32&#4294967295;pm, TideMan <mul...@gmail.com> wrote:
> On Apr 6, 9:29&#4294967295;am, "Jan Simon" <matlab.THIS_Y...@nMINUSsimon.de> > wrote: > > > > > Dear Luna! > > > > I have a vector of real numbers in Matlab. How do I compress them? &#4294967295;Of > > > course this has to be lossless, since I need to be able to recover > > > them. > > > > The goal is to study the Shannon rate and entropy of these real > > > numbers, so I decide to compress them and see how much compression > > > ratio I can have. > > > > I don't need to write the result into compressed files, so those > > > headers, etc. are just overhead for me which affect me calculating the > > > Entropy... so I just need a bare version of the compress ratio... > > > Michael Kleder's function compresses data in the memory with the zlib: > > &#4294967295;http://www.mathworks.com/matlabcentral/fileexchange/8899 > > > E.g. for sin(1:1e5) this saves 5% memory. 7-zip reduces the file by at least 25%. > > > Good luck, Jan > > An entirely different approach is "wavelet shrinkage". > Google it. > It's easy to do in Matlab if you have the wavelet toolbox. > I use the techniques for denoising and despiking, but I've never tried > to compress data with them. > I use Shannon entropy to figure out the optimum mother wavelet.
Sounds good. I guess the question is how to decide the Shannon entropy for a sequence of floating numbers?