matlab - 如何在同一 Canvas 上连续可视化matlab中的多个矩阵以制作视频?

标签 matlab visualization

我需要类似 this 的东西,但是我有很多描述二维电场随时间变化的矩阵。所以我希望矩阵可视化相互替换,以获得视频

最佳答案

我想给您一个示例代码,用于从一系列绘图生成动画 gif。您可以修改绘图以生成您喜欢的任何内容;例如您链接中的那个。

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

enter image description here
(来源:ismailari.com)

关于matlab - 如何在同一 Canvas 上连续可视化matlab中的多个矩阵以制作视频?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10671724/

相关文章:

matlab - 是否可以在 matlab 中进行 'stateless' 编程/如何避免检查数据完整性?

java - 如何覆盖matlab中的对象?

matlab - 这个 MATLAB 代码是如何工作的? (概率和随机序列)

matlab - 如何在 Linux 服务器上运行 matlab m 文件脚本

javascript - 使用 SVG 和 Javascript 的交互式有向图

javascript - vis.js 速度慢,有很多节点/边

python - 如何使用逻辑运算符访问和更改 Python 数组?

r - 为什么ggplot2中的facet_wrap()可以用波形符(~)或vars()来表示?

python - 如何可视化多维数据上的 kmeans 聚类

python - 将 MatplotLib 或自定义颜色图应用于 OpenCV 图像