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

Table6-2<br />

ASCIIDataImportFunctionFeatures(Continued)<br />

Function Data Type Delimiters<br />

Number<br />

of Return<br />

Values<br />

Notes<br />

fscanf<br />

Alphabetic<br />

and numeric;<br />

however,<br />

both types<br />

returned in a<br />

single return<br />

variable<br />

Any<br />

character<br />

One<br />

Part of low-level<br />

file I/O routines.<br />

Requires use of<br />

fopen to obtain<br />

file identifier and<br />

fclose after read.<br />

load Numeric data Spaces<br />

only<br />

One<br />

Easy to use. Use<br />

the functional<br />

form of load to<br />

specify the name<br />

of the output<br />

variable.<br />

textread<br />

Alphabetic<br />

and numeric<br />

Any<br />

character<br />

Multiple<br />

values in<br />

cell arrays<br />

Flexible, powerful,<br />

and easy to<br />

use. Use format<br />

string to specify<br />

conversions.<br />

textscan<br />

Alphabetic<br />

and numeric<br />

Any<br />

character<br />

Multiple<br />

values<br />

returned<br />

to one cell<br />

array<br />

More flexible<br />

than textread.<br />

Also more format<br />

options.<br />

Importing Numeric Text Data<br />

If your data file contains only numeric data, you can use many of the<br />

<strong>MATLAB</strong> import functions (listed in ASCII Data Import Function Features on<br />

page 6-77), depending on how the data is delimited. If the data is rectangular,<br />

that is, each row has the same number of elements, the simplest command<br />

to use is the load command. (The load functioncanalsobeusedtoimport<br />

MAT-files, the <strong>MATLAB</strong> binary format for saving the workspace.)<br />

6-78

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

Saved successfully!

Ooh no, something went wrong!