Hello!
I have encountered a very weird behaviour of the getframe function. I essentially create a new frame in a for loop by
figure(10)image(xvekt*1e6,yvekt*1e6,I2/max(max(I2))*64)hold onplot(D_core/2*cos(linspace(0,2*pi,50))*1e6,D_core/2*sin(linspace(0,2*pi,50))*1e6,'Color',[1 1 1]*0.6,'LineWidth',2)colormap(jet)hold offzoom(5)drawnowpause(.1)F(steg_nummer) = getframe;
Exactly what the code does is not very important, but notice the pause(0.1) before the getframe call to make sure getframe really captures the frame. steg_nummer is the iteration variable.
After the for loop, I attempt to save the animation by
v = VideoWriter('C:\newfile.avi');open(v);for k=1:length(F) k writeVideo(v,F(k))endclose(v)
But this fails. As above, I'm displaying the k for debugging purposes, and it appears that the cdata sometimes is a 0x0-matrix, which is weird.
The for loop
for k=1:length(F) disp(size(F(k).cdata))end
returns
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
0 0
0 0
344 436 3
0 0
0 0
Best Answer