It is easy to do using the VideoWriter class.
You easily add frame (Image) using the proper method which is writeVideo.
After creating a video object, videoObject and given an image by mImage001, adding frame is done by:
writeVideo(videoObject, mImage001);
Enjoy...
Code Sample
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
open(writerObj);
% Creating a figure.
% Each frame will be a figure data
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
set(gcf,'Renderer','zbuffer');
for k = 1:20
surf(sin(2*pi*k/20)*Z,Z)
% Frame includes image data
frame = getframe;
% Adding the frame to the video object using the 'writeVideo' method
writeVideo(writerObj,frame);
end
% Closing the file and the object using the 'Close' method
close(writerObj);
This should be straight forward.