2

このようなものが必要ですが、時間の経過に伴う2D電場の変化を表す行列がたくさんあります。ビデオを取得するために、マトリックスの視覚化を相互に置き換えたいと思います

4

1 に答える 1

2

一連のプロットからアニメーション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

ここに画像の説明を入力してください
(出典:ismailari.com

于 2012-05-20T12:22:54.083 に答える