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

Ifthefiletobemappedresidessomewhereonthe<strong>MATLAB</strong>path,youcanuse<br />

a partial pathname. If the path to the file is not fully specified, <strong>MATLAB</strong><br />

searches for the file in your current working directory first, and then on the<br />

<strong>MATLAB</strong> path.<br />

Once memmapfile locates the file, <strong>MATLAB</strong> stores the absolute pathname for<br />

the file internally, and then uses this stored path to locate the file from that<br />

point on. This enables you to work in other directories outside your current<br />

work directory and retain access to the mapped file.<br />

You can change the value of the Filename property at any time after<br />

constructing the memmapfile object. You might want to do this if<br />

• You want to use the same memmapfile object on more than one file.<br />

• You save your memmapfile object to a MAT-file, and then later load it back<br />

into <strong>MATLAB</strong> in an environment where themappedfilehasbeenmovedto<br />

a different location. This requires that you modify the path segment of the<br />

Filename string to represent the new location.<br />

For example, save memmapfile object m to file mymap.mat:<br />

disp(m.Filename)<br />

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

save mymat m<br />

Now move the file to another location, load the object back into <strong>MATLAB</strong>, and<br />

update the path in the Filename property:<br />

load mymat m<br />

m.Filename = 'f:\testfiles\oct1\records.dat'<br />

Note You can only map an existing file. You cannot create a new file and map<br />

that file to memory in one operation. Usethe<strong>MATLAB</strong>fileI/Ofunctionsto<br />

create the file before attempting to map it to memory.<br />

6-44

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

Saved successfully!

Ooh no, something went wrong!