matlab2018制作mp4

v = VideoWriter(‘test’,‘MPEG-4’); % 使用 H.264 编码的 MPEG-4 文件(Windows 7 或更高版本或者 Mac OS X 10.7 及更高版本的系统)
v.Quality = 95;
open(v)
for k = 1:100
A = mat2gray(rand(300));
writeVideo(v,A)
end
close(v)

把MATLAB 中的figure做成视频

v = VideoWriter(‘t.mp4’,‘MPEG-4’); % 使用 Motion JPEG 编码的mp4 文件
v.Quality = 95;
open(v)
figure;
for x = 1:1:10
for y = 1:1:10
rp1 = squeeze(rec13(x,y,:));
rp2 = squeeze(rec2(x,y,:));
sp = squeeze(rec3(x,y,:));
plot([rp1 rp2 sp]); title([’(’ num2str(x) ‘,’ num2str(y) ‘)’]);
legend(‘a3: mean’, ‘rec_ti’, ‘simu’);
grid on;
pause(0.01);
frame = getframe(gcf);
writeVideo(v,frame);
end
end
close(v)

你可能感兴趣的:(Matlab)