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

Saving from External Programs<br />

The <strong>MATLAB</strong> External Interfaces documentation provides details on reading<br />

and writing MAT-files from external C or Fortran programs. It is important to<br />

use recommended access methods, rather than rely upon the specific MAT-file<br />

format, which is likely to change in the future.<br />

Importing Data from MAT-Files<br />

This section covers<br />

• “Using the load Function” on page 6-30<br />

• “Previewing MAT-File Contents” on page 6-31<br />

• “Loading into a Structure” on page 6-31<br />

• “Loading Binary Data” on page 6-32<br />

• “Loading ASCII Data” on page 6-32<br />

Using the load Function<br />

To import variables from a binary or ASCII file on your disk to your<br />

workspace, use the load function. You can load all variables from the<br />

workspaceinasingleoperation(ifyouomitthefilename,<strong>MATLAB</strong>loads<br />

from file matlab.mat):<br />

load filename<br />

or load just those variables that you specify:<br />

load filename var1 var2 ... varN<br />

Usethewildcardcharacter(*)inthevariablenametoloadthosevariables<br />

that match a specific pattern. (This worksforMAT-filesonly.)Forexample,<br />

the following command loads all variables that start with str from file<br />

strinfo.mat:<br />

load strinfo str*<br />

6-30

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

Saved successfully!

Ooh no, something went wrong!