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

By default, if you do not specify a delimiter, dlmwrite uses a comma as a<br />

delimiter. You can specify a space (' ') as a delimiter or, if you specify empty<br />

quotes (''), no delimiter.<br />

Using the diary Function to Export Data<br />

To export small numeric arrays or cell arrays, you can use the diary function.<br />

diary creates a verbatim copy of your <strong>MATLAB</strong> session in a disk file<br />

(excluding graphics).<br />

For example, if you have the array A in your workspace,<br />

A = [ 1 2 3 4; 5 6 7 8 ];<br />

execute these commands at the <strong>MATLAB</strong> prompt to export this array using<br />

diary:<br />

1 Turn on the diary function. You can optionally name the output file diary<br />

creates.<br />

diary my_data.out<br />

2 Display the contents of the array you want to export. This example displays<br />

the array A. You could also display a cell array or other <strong>MATLAB</strong> data type.<br />

A =<br />

1 2 3 4<br />

5 6 7 8<br />

3 Turn off the diary function.<br />

diary off<br />

diary creates the file my_data.out and records all the commands executed<br />

in the <strong>MATLAB</strong> session until it is turned off.<br />

A =<br />

1 2 3 4<br />

5 6 7 8<br />

6-87

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

Saved successfully!

Ooh no, something went wrong!