%% Create VideoWriter Object and Write Video
% Write a video to a file by creating an array with random data, making a VideoWriter object for the output file, and then writing the array to the video.
%
% Create a 300-by-300 matrix of data.

A = rand(300);

%
%  Create a VideoWriter object to write a Motion JPEG AVI file named newfile.avi and open the file for writing.

v = VideoWriter('newfile.avi');
open(v)

%
% Write the matrix of data A to the video file.

writeVideo(v,A)

%
% Close the file.

close(v)

% Copyright 2015 The MathWorks, Inc.