How to loop images using for loop and making it run on mp4

I want to loop 4 images onto a mp4 player as a result im stuck on the looping using for loop may anyone help me.
My Code:
x = VideoWriter('myAnimation','MPEG-4');
x.FrameRate = 0.5;
x.VideoCompressionMethod
open(x);
for B = 1:5;
Bimread('mob.jpg'); %inputting images here!
C = imresize(B, .25);
end
writeVideo(x,C);
close(x);
*Im not sure where the

Answers (2)

After you've created the video, use movie() to play it.
I have a mp4 video but will not loop all my images.
Here is my new code:
%% My Animation
x = VideoWriter('myAnimation','MPEG-4');
x.FrameRate = 0.5;
open(x);
imfile{1}='mob.jpg';
imfile{2}='parkes.jpg';
imfile{3}='mob.jpg';
for i=1:3
img = imread(imfile{i}); % process img here if you wish
figure;
imshow(img);
end
writeVideo(x,C);
close(x);

Asked:

on 9 Nov 2016

Commented:

on 9 Nov 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!