How to animate a cosine plot using getframe

Hi, I'm pretty new to Matlab and I've been playing around trying to animate a 2D cosine graph using the getframe function. Here's my code
t=0:pi/100:10;
tlength = numel(t);
for i=1:tlength
plot(cos(t));
F(:,i) = getframe;
end
movie(F);
But when I try running it it's not animated at all, just a still plot. What am I doing wrong?

 채택된 답변

KSSV
KSSV 2020년 9월 28일

1 개 추천

t=0:pi/100:10;
tlength = numel(t);
for i=1:tlength
plot(cos(1:t(i)));
F(:,i) = getframe;
end
movie(F);
Also read about comet
t=0:pi/100:10;
y = cos(t) ;
comet(t,y)

댓글 수: 2

jm
jm 2020년 9월 28일
Thank you so so so much!
KSSV
KSSV 2020년 9월 28일
Thanks is accepting the answer... :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Animation에 대해 자세히 알아보기

태그

질문:

jm
2020년 9월 28일

댓글:

2020년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by