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.

Exporting Text Data<br />

Table 6-4<br />

ASCII Data Export Function Features<br />

Function Use With Delimiters Notes<br />

csvwrite<br />

Numeric<br />

data<br />

Commas only<br />

Primarily used with<br />

spreadsheet data.<br />

See “Working with<br />

Spreadsheets” on page<br />

6-97.<br />

diary<br />

Numeric<br />

data or cell<br />

array<br />

Spaces only<br />

Can be used for small<br />

arrays. Requires editing<br />

of data file to remove<br />

extraneous text.<br />

dlmwrite<br />

Numeric<br />

data<br />

Any character<br />

Easy to use, flexible.<br />

fprintf<br />

Alphabetic<br />

and numeric<br />

data<br />

Any character<br />

Part of low-level file I/O<br />

routines. This function<br />

is the most flexible but<br />

also the most difficult to<br />

use. You must use fopen<br />

to obtain a file identifier<br />

before writing the data<br />

and fclose to close the file<br />

after writing the data.<br />

save<br />

Numeric<br />

data<br />

Tabs or spaces<br />

Easy to use; output values<br />

are high precision.<br />

Exporting Delimited ASCII Data Files<br />

To export an array as a delimited ASCII data file, you can use either the<br />

save function, specifying the -ASCII qualifier, or the dlmwrite function. The<br />

save function is easy to use; however, the dlmwrite function provides more<br />

flexibility, allowing you to specify any character as a delimiter and to export<br />

subsets of an array by specifying a range of values.<br />

Using the save Function<br />

To export the array A,<br />

6-85

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

Saved successfully!

Ooh no, something went wrong!