23.06.2015 Views

MATLAB Programming

MATLAB Programming

MATLAB Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

6 Data Import and Export<br />

Writable: false<br />

Offset: 0<br />

Format: 'uint8'<br />

Repeat: Inf<br />

Data: 40000x1 uint8 array<br />

<strong>MATLAB</strong> constructs an instance of the memmapfile class, assigns it to the<br />

variable m, andmapstheentirerecords.dat file to memory, setting all<br />

properties of the object to their default values. In this example, the command<br />

maps the entire file as a sequence of unsigned 8-bit integers, and gives the<br />

caller read-only access to its contents.<br />

Changing Property Values<br />

You can make the memory map more specific to your needs by including<br />

more information when calling the constructor. In addition to the filename<br />

argument, there are four other parameters that you can pass to the<br />

constructor. Each of these parameters represents a property of the object, and<br />

each requires an accompanying value to be passed as well:<br />

objname = memmapfile(filename, prop1, value1, prop2, value2, ...)<br />

For example, to construct a map using nondefault values for the Offset,<br />

Format, andWritable properties, type the following, enclosing all property<br />

names and string parameter values in quotes:<br />

m = memmapfile('records.dat', ...<br />

'Offset', 1024, ...<br />

'Format', 'double', ...<br />

'Writable', true);<br />

Typetheobjectnametoseethecurrentsettingsforallproperties:<br />

m<br />

m =<br />

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

Writable: true<br />

Offset: 1024<br />

Format: 'double'<br />

Repeat: Inf<br />

6-42

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

Saved successfully!

Ooh no, something went wrong!