No BSD License  

Highlights from
Rapid lossless data compression of numerical or string variables

5.0

5.0 | 11 ratings Rate this file 37 Downloads (last 30 days) File Size: 1.86 KB File ID: #8899

Rapid lossless data compression of numerical or string variables

by

 

01 Nov 2005 (Updated )

Rapidly compresses (or decompresses) Matlab variables in memory

| Watch this File

File Information
Description

Using the public domain ZLIB Deflator algorithm, these two functions (DZIP and DUNZIP) losslessly compress or decompress MATLAB variables of most data types so that they occupy less space. Class type and variable size and shape are stored within the compressed data.

NOTES:
(1) The input variable can be a scalar, vector, matrix, or n-dimensional matrix
(2) The input variable must be a non-complex and full (meaning matrices declared as type "sparse" are not allowed)
(4) In testing, DZIP compresses several megabytes of data per second.
(5) In testing, sparsely populated matrices or matrices with regular structure can compress to less than 10% of their original size. The realized compression ratio is heavily dependent on the data. (For example, a large stream of truly random data is theoretically impossible to compress.)
(6) Variables originally occupying very little memory (less than about half of one kilobyte) are handled correctly, but the compression requires some overhead and may actually increase the storage size of such small data sets. One exception to this rule is noted next.
(7) LOGICAL variables are compressed to a small fraction of their original sizes.
(8) The DUNZIP function decompresses the output of this function and restores the original data, including size and class type.
(9) This function uses the public domain ZLIB Deflater algorithm.
(10) Carefully tested, but no warranty; use at your own risk.
(11) Michael Kleder, Nov 2005

Acknowledgements

This file inspired Dicom Operator Esme Process and Compression Routines.

MATLAB release MATLAB 7.0.4 (R14SP2)
Other requirements Java is called by these functions.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
01 Aug 2014 Jasper

Works great. Clean code as well.

12 Jul 2013 AMITAVA BISWAS  
29 Jan 2013 osama bushnaq  
28 Nov 2012 Xiaohu  
14 Aug 2012 Charlie

I have data that I believe was compressed using the zlib library (http://zlib.net/).

Using this script I get the error:

Subscript indices must either be real positive integers or logicals.

Error in dunzip (line 37)
M = typecast(Q,ct{cn});

This error is produced because c at line 23 is not assigned to any value.

I tried making the change suggested by Jesse Hopkins above, but got a different error as follows:
Java exception occurred:
java.io.IOException: Not in GZIP format

at java.util.zip.GZIPInputStream.readHeader(Unknown Source)

at java.util.zip.GZIPInputStream.<init>(Unknown Source)

at java.util.zip.GZIPInputStream.<init>(Unknown Source)

Error in dunzip_ch (line 23)
b=java.util.zip.GZIPInputStream(a);

Do you have any suggestions of what my mistake is?

27 Jan 2011 ali reza

very nice

05 Nov 2010 Fabian

Is there a way to use these functions to load gzpped ascii-csv-files into Matlab?

22 Feb 2010 Jim Crozier  
26 Oct 2009 Jesse Hopkins

Needed to make the following changes to eliminate above java exceptions (in R2008b)

dzip.m line 48: change "DeflaterOutputStream" to "GZIPOutputStream"

dunzip.m line 21: change "InflaterInputStream" to "GZIPInputStream"

21 Oct 2009 Jesse Hopkins

Using R2008b an exception occurs at line 24 of dunzip:
??? Java exception occurred:
java.util.zip.ZipException: unknown compression method

at java.util.zip.InflaterInputStream.read(Unknown Source)

at java.io.FilterInputStream.read(Unknown Source)

at com.mathworks.mlwidgets.io.InterruptibleStreamCopier.copyStream(InterruptibleStreamCopier.java:97)

at com.mathworks.mlwidgets.io.InterruptibleStreamCopier.copyStream(InterruptibleStreamCopier.java:76)

Any thoughts on what needs to be changed?

23 Dec 2008 rajchandar k

hello every one.. how to use this files with Rapid AES algorithm explain with procedure...

thank U......

31 Oct 2007 Zack Voulgaris

An exceptional piece of code. Short, fast and effective.

26 Jul 2007 Matlab User

A simple, easy to use file that made my application not eat up 1.5 gigs+ of memory. Thumbs up.

18 Mar 2007 Pranas Baliuka

Thanks! KISS. Excellent. I wonder why Mathworks did not create as standart e.g. in communication toolbox or even in core ...

18 Nov 2005 Matlab User

Very clever, very simple
Thanks a lot!

Updates
03 Nov 2005

comment clarifications

Contact us