v1 = VideoReader('XXXXXXX.avi')
v2 = VideoReader('XXXXXXX.avi')
i1 = 0;
i2 = 0;
fig = gcf;
ax1 = subplot(2,2,1, 'Parent', fig);
ax2 = subplot(2,2,2, 'Parent', fig);
while i1 < v1.NumberOfFrames && i2 < v2.NumberOfFrames
if i1 < v1.NumberOfFrames
i1 = i1+1;
if ishandle(ax1)
image(ax1, v1.read(i1));
else
break;
end
end
if i2 < v2.NumberOfFrames
i2 = i2+1;
if ishandle(ax2)
image(ax2, v2.read(i2));
else
break;
end
end
drawnow
end
Note: in R2014b or later, it would be better to use isgraphics() instead of ishandle()
Best Answer