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 />

• For small files that you want to read into memory once and access<br />

frequently<br />

• For data that you want to share between applications<br />

• When you want to work with data in a file as if it were a <strong>MATLAB</strong> array<br />

When the Advantage Is Less Significant. The following types of files do<br />

not fully utilize the benefits of memory-mapping:<br />

• Formatted binary files like HDF or TIFF that require customized readers<br />

are not good for memory-mapping. For one thing, describing the data<br />

contained in these files can be a very complex task. Also, you cannot access<br />

data directly from the mapped segment, but must instead create arrays<br />

to hold the data.<br />

• Text or ASCII files require that you convert the text in the mapped region<br />

toanappropriatetypeforthedatatobemeaningful. Thistakesup<br />

additional address space.<br />

• Files that are larger than several hundred megabytes in size consume a<br />

significant amount of the virtual address space needed by <strong>MATLAB</strong> to<br />

processyourprogram. Mappingfilesofthissizemayresultin<strong>MATLAB</strong><br />

reporting out-of-memory errors more often. This is more likely if <strong>MATLAB</strong><br />

has been running for some time, or if the memory used by <strong>MATLAB</strong><br />

becomes fragmented.<br />

ThememmapfileClass<br />

<strong>MATLAB</strong> implements memory-mapping using an object-oriented class called<br />

memmapfile. Thememmapfile classhasthepropertiesandmethodsyouneed<br />

tomaptoafile,readandwritethefileviathemap,andremovethemapfrom<br />

memory when you are done.<br />

Properties of the memmapfile Class<br />

There are six properties defined for the memmapfile class. These are shown in<br />

the table below. These properties control which file is being mapped, where in<br />

thefilethemappingistobeginandend, how the contents of the file are to<br />

be formatted, and whether or not the file is writable. One property of the file<br />

contains the file data itself.<br />

6-38

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

Saved successfully!

Ooh no, something went wrong!