It is easy to do using the VideoWriter class.
You easily add frame (Image) using the proper method which is
After creating a video object,
videoObject and given an image by
mImage001, adding frame is done by:
Here is a code sample based on Mathworks documentation with some remarks of mine:
% Creating Video Writer Object
writerObj = VideoWriter('peaks.avi');
% Using the 'Open` method to open the file
% Creating a figure.
% Each frame will be a figure data
Z = peaks; surf(Z);
for k = 1:20
% Frame includes image data
frame = getframe;
% Adding the frame to the video object using the 'writeVideo' method
% Closing the file and the object using the 'Close' method
This should be straight forward.