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

d = m.Data;<br />

whos d<br />

Name Size Bytes Class<br />

d 100x1 800 double array<br />

Grand total is 100 elements using 800 bytes<br />

Read a selected set of numbers from the file by indexing into the<br />

single-precision array m.Data:<br />

d(15:20)<br />

ans =<br />

1.0e+009 *<br />

3.6045<br />

2.7006<br />

0.5745<br />

0.8896<br />

2.6079<br />

2.7053<br />

Example 2 — Formatting File Data as a Matrix<br />

This example is similar to the last, except that the constructor of the<br />

memmapfile object now specifies an array shape of 4-by-6 to be applied to the<br />

data as it is read from the mapped file. <strong>MATLAB</strong> maps the file contents into a<br />

structure array rather than a numeric array, as in the previous example:<br />

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

'Format', {'double', [4 6], 'x'}, ...<br />

'Offset', 1024, 'Repeat', 100);<br />

d = m.Data;<br />

whos d<br />

Name Size Bytes Class<br />

d 100x1 25264 struct array<br />

Grand total is 2500 elements using 25264 bytes<br />

6-56

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

Saved successfully!

Ooh no, something went wrong!