MATLAB Answers

How can I animate my plot?

2 views (last 30 days)
Nuri Öztürk
Nuri Öztürk on 8 Jun 2017
Commented: KSSV on 5 Nov 2020
x=randn(2,10000); a=x(1,:); b=x(2,:); figure;plot(a,b,'.')
  1 Comment
Chad Greene
Chad Greene on 8 Jun 2017
comet(a,b)
produces an animation. If you want a more specific solution, you'll have to ask a more specific question.

Sign in to comment.

Accepted Answer

KSSV
KSSV on 9 Jun 2017
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 Comments
KSSV
KSSV on 5 Nov 2020
I didn't get your question @rotton. Any example? So that we can undestand it with ease.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!