How can I animate my plot?

조회 수: 10 (최근 30일)
Nuri Öztürk
Nuri Öztürk 2017년 6월 8일
댓글: KSSV 2020년 11월 5일
x=randn(2,10000); a=x(1,:); b=x(2,:); figure;plot(a,b,'.')
  댓글 수: 1
Chad Greene
Chad Greene 2017년 6월 8일
comet(a,b)
produces an animation. If you want a more specific solution, you'll have to ask a more specific question.

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

채택된 답변

KSSV
KSSV 2017년 6월 9일
x=randn(2,10000);
a=x(1,:);
b=x(2,:);
% figure;
% plot(a,b,'.')
figure(1)
axis([min(a) max(a) min(b) max(b)])
hold on
filename = 'test.gif';
for n = 1:length(a)
plot(a(n),b(n),'.')
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if n == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
  댓글 수: 3
winkmal
winkmal 2020년 11월 4일
Nice, but I think 100 (instead of 1e5) points is enough for demonstration purposes. 😉 Otherwise, file grows > 125 MB!
Any chance to have the different layers appear on click, instead of after a fixed time? That would be useful for embedding in presentations.
KSSV
KSSV 2020년 11월 5일
I didn't get your question @rotton. Any example? So that we can undestand it with ease.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by