MATLAB: Forming Video from frames but getting the error

for loopimage analysisimage processingindexingvariablesvideo processing

Hi,
I am trying to made a video using images (30 fps) but I am getting an error which I am failing to understand or correct it. Both code and error shown below.
Thanks for the help in advance!
Code:
%Read the Images
for m=2:10
images =imread(sprintf('frame%d.jpg',m));%name of files are frame2.jpg till frame190.jpg so on
end
% create the video writer with 30 fps
writerObj = VideoWriter('myVideo.avi');
writerObj.FrameRate = 30;
% open the video writer
open(writerObj);
% write the frames to the video
for u=1:length(images)
% convert the image to a frame
frame = im2frame(images{u});
end
% close the writer object
close(writerObj);
Error:
Brace indexing is not supported for variables of this type.
Error in videowriter (line 16)
frame = im2frame(images{u});

Best Answer

for m=2:10
images =imread(sprintf('frame%d.jpg',m));%name of files are frame2.jpg till frame190.jpg so on

end
That loop overwrites all of images each time.
for m=2:10
images{m-1} =imread(sprintf('frame%d.jpg',m));%name of files are frame2.jpg till frame190.jpg so on
end