I made a 2D color plot, how do I turn the plot into an animation or video of the points being put into place? Thanks

조회 수: 6 (최근 30일)
The plots differ in color based on the Z value.

답변 (5개)

Image Analyst
Image Analyst 2013년 7월 17일

Youssef  Khmou
Youssef Khmou 2013년 7월 17일
hi,
If you mean you have a plot from 2 vectors x and y, then you can use the function pause to drawn each point :
for n=1:length(x)
plot(x(n),y(n))
pause(N), % where N is numbers of seconds
hold on,
end

Union Colleg
Union Colleg 2013년 7월 17일
Thank you very much these have both been very helpful as I am just starting up in the matlab world.

Shane
Shane 2013년 7월 18일
편집: Shane 2013년 7월 18일
The comet function is also quite nice.
X = sin(0:.01:2*pi);
comet(X)
%or
X = sin(0:.01:2*pi);
Y = 0:.01:2*pi;
comet(X,Y)
  댓글 수: 1
Image Analyst
Image Analyst 2013년 7월 18일
Yes, though it could be even better if there were some way to control the speed of the comet and length of the tail.

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


Ricardo A. Baila
Ricardo A. Baila 2016년 7월 6일
You might want to check out:
doc animatedline
Example from the documentation:
Create the initial animated line object. Then, use a loop to add 1,000 points to the line. After adding each new point, use drawnow to display the new point on the screen.
h = animatedline;
axis([0,4*pi,-1,1])
x = linspace(0,4*pi,1000);
y = sin(x);
for k = 1:length(x)
addpoints(h,x(k),y(k));
drawnow
end
(And you can control the drawing speed up to a certain degree by resourcing to the pause command)

카테고리

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