23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

6 Data Import and Export<br />

Data Compression<br />

<strong>MATLAB</strong> compresses the data that you savetoaMAT-file.Datacompression<br />

can save you a significant amount of storage space when you are working with<br />

large files or working over a network.<br />

Data compression is optional, however, and you can disable it either for an<br />

individual save operation, or for all of your <strong>MATLAB</strong> sessions. Use the -v6<br />

option with the save function to turn off compression on a per-command basis:<br />

save filename -v6<br />

To disable data compression for all of your <strong>MATLAB</strong> sessions, open the<br />

Preferences dialog, select General and then MAT-Files, and click the option<br />

that is equivalent to the command save -v6. See General Preferences for<br />

<strong>MATLAB</strong> in the Desktop Tools and Development Environment documentation<br />

for more information.<br />

Note You cannot read a compressed MAT-file with <strong>MATLAB</strong> versions earlier<br />

thanVersion7.TowriteaMAT-filethatyouwillbeabletoreadwithoneof<br />

these versions, save to the file with data compression disabled.<br />

Information returned by the command whos -file is independent of whether<br />

the variables in that file are compressed or not. The byte counts returned by<br />

this command represent the number of bytes data occupies in the <strong>MATLAB</strong><br />

workspace, and not in the file the data was saved to.<br />

Evaluating When to Compress. You should consider both data set size<br />

and the type of data being saved when deciding whether or not to compress<br />

the data you save to a file. The benefits of data compression are greater<br />

when saving large data sets (over 3 MB), and are usually negligible with<br />

smaller data sets. Data that has repeating patterns or more consistent values<br />

compresses better than random data. Compressing data that has a random<br />

pattern is not recommended as it slows down the performance of save and<br />

load significantly, and offers little benefit in return.<br />

In general, data compression and decompression slows down all save and<br />

some load operations to some extent. In most cases, however, the resulting<br />

reductioninfilesizeisworththeadditional time spent compressing or<br />

6-26

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!