JohnnyF
JohnnyF

Reputation: 1101

Creating moving dot plot in MATLAB to video

I have 2 matrices

size(X)=size(y)=3600*140

They represent 140 nodes position in 3600 secs I would like to create a movie of dots what will show them moving let say each 0.001sec will show next all node position

i did:

for ii=1:3600
plot(x(ii,:),y(ii,:));
pause(0.0001);
end

Now it shows me the moving dots as wanted but

I would like each dot to have a colour I would like to make a movie of those plots

Upvotes: 0

Views: 508

Answers (1)

JohnnyF
JohnnyF

Reputation: 1101

here i got it to work. hope it will help someone else

writerObj = VideoWriter('runningNodes.avi');
open(writerObj);
plot(x(1,:),y(1,:));
axis tight
set(gca,'nextplot','replacechildren');
set(gcf,'Renderer','zbuffer');
for ii=1:3600
   plot(x(ii,:),y(ii,:));
   frame = getframe;
   writeVideo(writerObj,frame);
end

close(writerObj);

Upvotes: 1

Related Questions