如何在matlab中在同一画布上连续显示多个矩阵以制作视频?
我需要类似的东西,但我有很多矩阵,它们描述了二维电场随时间的变化。因此,我希望矩阵可视化相互替换,以获得视频,我想给您一个示例代码,从一系列绘图生成动画gif。您可以修改绘图以生成您喜欢的任何内容;e、 g.链接中的那个如何在matlab中在同一画布上连续显示多个矩阵以制作视频?,matlab,visualization,Matlab,Visualization,我需要类似的东西,但我有很多矩阵,它们描述了二维电场随时间的变化。因此,我希望矩阵可视化相互替换,以获得视频,我想给您一个示例代码,从一系列绘图生成动画gif。您可以修改绘图以生成您喜欢的任何内容;e、 g.链接中的那个 gifOutputName = 'sample.gif'; %# As an example, let us draw a 3-D plot %# You can generalize it to anything you like Z = peaks; surf(Z); a
gifOutputName = 'sample.gif';
%# As an example, let us draw a 3-D plot
%# You can generalize it to anything you like
Z = peaks; surf(Z);
axis tight
set(gca,'nextplot','replacechildren');
for j = 1:20
surf(sin(2*pi*j/20)*Z,Z)
%# Grab the current frame
RGB = frame2im(getframe(gcf));
%# Reduce it to 256 colors since it's gonna be GIf image
[IND, map] = rgb2ind(RGB, 256);
if j == 1 % Vreate in the first step
%# 'LoopCount' indicates how many times the animation will play,
%# Inf states infinity. Refer to "GIF-Specific Parameters" in the
%# documentation.
imwrite(IND, map, gifOutputName, 'gif', 'LoopCount', Inf);
else %# Otherwise, append it to the previous
imwrite(IND, map, gifOutputName, 'gif', 'WriteMode', 'append');
end
end
close %# Close the figure
(来源:)我不明白如何在同一“画布”上顺序加载和可视化具有不同名称(例如:1.dat、2.dat、3.dat、4.dat等)矩阵的文件