|On this page…|
In MATLAB®, audio data is simply numeric data that you can export using standard MATLAB data export functions, such as save.
You also can export audio data to files in specific file formats using the audiowrite function.
To create an Audio/Video Interleaved (AVI) file from MATLAB graphics animations or from still images, follow these steps:
Create a VideoWriter object by calling the VideoWriter function. For example:
myVideo = VideoWriter('myfile.avi');
By default, VideoWriter prepares to create an AVI file using Motion JPEG compression. To create an uncompressed file, specify the Uncompressed AVI profile, as follows:
uncompressedVideo = VideoWriter('myfile.avi', 'Uncompressed AVI');
Optionally, adjust the frame rate (number of frames to display per second) or the quality setting (a percentage from 0 through 100). For example:
myVideo.FrameRate = 15; % Default 30 myVideo.Quality = 50; % Default 75
Open the file:
Write frames, still images, or an existing MATLAB movie to the file by calling writeVideo. For example, suppose that you have created a MATLAB movie called myMovie. Write your movie to a file:
Alternatively, writeVideo accepts single frames or arrays of still images as the second input argument. For more information, see the writeVideo reference page.
Close the file: