Using VideoWriter to make a Movie without Displaying the Figure each time
2 次查看(过去 30 天)
显示 更早的评论
I have a variable called movie which is a multidimensional array of a solution to a partial differential equation at every kth time step. I now want to use VideoWriter to make a movie out of this variable. However, it seems to take forever in run-time because Matlab is actually displaying each frame on the screen. Is there anyway to speed this up? My code for this section is attached below:
%%
clf;
vid = VideoWriter('movie_2D.avi');
vid.FrameRate = 20;
open(vid);
frames = 1000;
for i=1:frames
figure(1);
surf(X,Z,movie(:,:,1+(t_max/frames)*i));
colormap parula; shading interp; grid off; colorbar; caxis([-1,1]);
xlim([-x_Max, x_Max])
ylim([0, 1])
% title('N=%d, M=%d, \Delta t=$d, \lambda_0=%d, \lambda_H=%d',N,M,dt,lambda0,lambdaH)
title('N=64, M=32, \Delta t=.0001, \lambda_0=100, \lambda_H=10')
xlabel('x')
ylabel('y')
zlabel('u')
view(0,90);
fig = gcf;
frame = getframe(fig);
writeVideo(vid,frame);
end
close(vid)
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!