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

For example, say that you map a file that is 12K bytes in length. Data read<br />

from this file could be treated as a sequence of 6,000 16-bit (2-byte) integers,<br />

or as 1,500 8-byte double-precision floating-point numbers, to name just a<br />

couple of possibilities. Or you could read this data in as a combination of<br />

different types: for example, as 4,000 8-bit (1-byte) integers followed by 1,000<br />

64-bit (8-byte) integers. You determine how <strong>MATLAB</strong> will interpret the<br />

mapped data by setting the Format property of the memmapfile object when<br />

you call its constructor.<br />

Note <strong>MATLAB</strong> arrays are stored on disk in column-major order. (The<br />

sequence of array elements is column 1, row1;column1,row2;column1,last<br />

row; column 2, row 1, and so on.) You might need to transpose or rearrange<br />

the order of array elements when reading or writing via a memory map.<br />

Note The Sol64 platform supports aligned data access only. If you attempt to<br />

use a memmapfile format on Sol64 that does not take the necessary alignment<br />

considerations into account, <strong>MATLAB</strong> generates an error. (See “Aligned<br />

Access on Sol64” on page 6-37).<br />

Data types supported for the Format property are shown at the end of this<br />

section. See “Supported Data Types for the Format Property” on page 6-51.<br />

For more information on format options see<br />

• “Mapping a Single Data Type” on page 6-46<br />

• “Formatting the Mapped Data to an Array” on page 6-47<br />

• “Mapping Multiple Data Types and Arrays” on page 6-49<br />

Mapping a Single Data Type. If the file region being mapped contains data<br />

of only one type, specify the Format value as a character string identifying<br />

that type:<br />

objname = memmapfile(filename, 'Format', datatype)<br />

6-46

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

Saved successfully!

Ooh no, something went wrong!