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.

Accessing Files with Memory-Mapping<br />

Data: 4872x1 double array<br />

You can also change the value of any property after the object has been<br />

constructed. Use the syntax<br />

objname.property = newvalue;<br />

Forexample,tosettheformattouint16, type the following. (Property names,<br />

like Format, arenotcasesensitive.)<br />

m.format = 'uint16'<br />

m =<br />

Filename: 'd:\matlab\mfiles\records.dat'<br />

Writable: true<br />

Offset: 1024<br />

Format: 'uint16'<br />

Repeat: Inf<br />

Data: 19488x1 uint16 array<br />

Further read and write operations to the region mapped by m will now treat<br />

the data in the file as a sequence of unsigned 16-bit integers. Whenever you<br />

change the value of a memmapfile property, <strong>MATLAB</strong> remaps the file to<br />

memory.<br />

Selecting the File to Map<br />

filename is the only required argument when you call the memmapfile<br />

constructor. When you call the memmapfile constructor, <strong>MATLAB</strong> assigns the<br />

filename that you specify to the Filename property of the new object instance.<br />

Specify the filename as a quoted string, (e.g., 'records.dat'). It must be first<br />

in the argument list and not specified as a parameter-value pair. filename<br />

must include a filename extension if the name of the file being mapped has an<br />

extension. The filename argument cannot include any wildcard characters<br />

(e.g., * or ?), and is not case sensitive.<br />

Note Unlike the other memmapfile constructor arguments, you must specify<br />

filename as a single string, and not as a parameter-value pair.<br />

6-43

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

Saved successfully!

Ooh no, something went wrong!