フィルターのクリア

Animating a sine wave movie

23 ビュー (過去 30 日間)
tyler brecht
tyler brecht 2014 年 10 月 23 日
コメント済み: Image Analyst 2016 年 5 月 12 日
Hi guys I would like to know how to make a movie of a sine wave using handle graphics and for each frame a for loop with getframe
a = -1; z = 0:pi/1000:2*pi; y = a*sin(z)

採用された回答

Image Analyst
Image Analyst 2014 年 10 月 23 日
See my attached demo. Just change the surf() call to plot() and it should work.
  1 件のコメント
tyler brecht
tyler brecht 2014 年 10 月 23 日
Thanks a lot!

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

その他の回答 (1 件)

Ced
Ced 2014 年 10 月 23 日
編集済み: Ced 2014 年 10 月 23 日
Something like that? (reduced the number of frames)
clear all
clc
close all
a = -1;
z = 0:pi/100:2*pi;
y = a*sin(z);
Nz = length(z);
% Set up your plot environment
figure
h = plot(z(1),y(1));
xlim([z(1) z(end)])
ylim([min(y) max(y)])
xlabel('z')
ylabel('a*sin(z)')
legend('my sine function')
init_getframe = struct('cdata',[],'colormap',[]);
frames = repmat(init_getframe, Nz, 1 );
frames(1) = getframe;
% Get frames
for i = 2:Nz
set(h,'XData',z(1:i));
set(h,'YData',y(1:i));
drawnow
frames(i) = getframe;
end
% Play movie
movie(frames)
But from experience, I prefer to save each frame to a file (e.g. .png), and then combine the frames later into a movie.
*EDIT*: I was a bit too slow. Make sure to check out Image Analysts answer for some extra frame size settings etc.
  4 件のコメント
BHANESH BHADRECHA
BHANESH BHADRECHA 2016 年 5 月 12 日
What if i want to increase the speed of animation, i mean i want to show more data samples at a time.
please reply with an answer.
Image Analyst
Image Analyst 2016 年 5 月 12 日
Set the framerate property of the video writer.

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

カテゴリ

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