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

Exporting Audio/Video Data<br />

<strong>MATLAB</strong> includes several functions that you can use to export audio or video<br />

data from the <strong>MATLAB</strong> workspace. These functions write audio data to a file<br />

using specific file formats. The following sections describe<br />

• “Exporting Audio Data” on page 6-94<br />

• “Exporting Video Data in AVI Format” on page 6-94<br />

This section also provides an example of writing video data to a file in<br />

“Example: Creating an AVI file” on page 6-95.<br />

Exporting Audio Data<br />

In <strong>MATLAB</strong>, audio data is simply numeric data that you can export using<br />

standard <strong>MATLAB</strong> data export functions, such as save.<br />

<strong>MATLAB</strong> also includes several functions that write audio data to files in<br />

specific file formats:<br />

• auwrite —Exports sound data in AU file format<br />

• wavwrite —Exports sound data in WAV file format<br />

Exporting Video Data in AVI Format<br />

You can export <strong>MATLAB</strong> video data as an Audio/Video Interleaved (AVI) file.<br />

To do this, you use the avifile function to create an avifile object. Once<br />

you have the object, you can use AVI file object methods and properties to<br />

control various aspects of the data export process.<br />

For example, in <strong>MATLAB</strong>, you can save a sequence of graphs as a movie<br />

that can then be played back using the movie function. You can export a<br />

<strong>MATLAB</strong> movie bysavingitinMAT-fileformat,likeanyother<strong>MATLAB</strong><br />

workspace variable. However, anyone who wants to view your movie must<br />

have <strong>MATLAB</strong>. (For more information about <strong>MATLAB</strong> movies, see the<br />

Animation section in the <strong>MATLAB</strong> Graphics documentation.)<br />

To export a sequence of <strong>MATLAB</strong> graphs in a format that does not require<br />

<strong>MATLAB</strong> for viewing, save the figures in Audio/Video Interleaved (AVI)<br />

6-94

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

Saved successfully!

Ooh no, something went wrong!