[Animation]: To animate a figure as function of several variables

5 ビュー (過去 30 日間)
Shobhit
Shobhit 2013 年 11 月 21 日
編集済み: Shobhit 2013 年 11 月 21 日
Hi, I have a function(my_figure) that creates a figure by taking an array of variables(q) as argument and plotting according to the values of those variables.
my_figure(q)
I wish to animate a collection of such figures by varying the array of variables in a loop. I have come across 'refresh data' but cannot figure out how that is supposed to help me. Please help.

回答 (1 件)

Grzegorz Knor
Grzegorz Knor 2013 年 11 月 21 日
See getframe and movie functions in the MATLAB documentation.There is a following example:
Z = peaks;
figure('Renderer','zbuffer');
surf(Z);
axis tight;
set(gca,'NextPlot','replaceChildren');
for j = 1:20
surf(sin(2*pi*j/20)*Z,Z)
F(j) = getframe;
end
movie(F,20) % Play the movie twenty times
  1 件のコメント
Shobhit
Shobhit 2013 年 11 月 21 日
編集済み: Shobhit 2013 年 11 月 21 日
Thanks for your reply. It helps. But I seem to be getting an error that:
Error using hgMovie
Movie contains uninitialized frames
Error in movie (line 41)
builtin('hgMovie',varargin{:});
I can see that All the frames have been alloted a value. I cannot understand the reason for this error.
I have given a part of my code for reference.
figure;
a_plot_m(q_eq);
axis tight;
set(gca,'NextPlot','replaceChildren');
for j =1:10
qm=q2(:,j);
car_plot_m(q_eq)
F(j) = getframe(gcf);
end
movie(F,10) % Play the movie

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAnimation についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by