필터 지우기
필터 지우기

Why is my surface graph not animating?

조회 수: 3 (최근 30일)
Richard Batelaan
Richard Batelaan 2020년 7월 4일
답변: Gouri Chennuru 2020년 7월 7일
I am trying to animate a surface defined by p(x,y,t), but drawnow and pause do not seem to work. Here is my code:
figure
for l=1:100
clf
surf(x, y, p(:,:,l))
zlim([-2 2])
shading interp
drawnow
pause(0.2)
end
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 7월 4일
Do not use clf in your loop.
You do not have "hold on" set, so already the surf() call is going to cla() for you, no need to force it to build an entire new axes.

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

답변 (1개)

Gouri Chennuru
Gouri Chennuru 2020년 7월 7일
Hi Richard,
you can refer to this documentation link which shows how to animate a surface.
clf deletes all graphics objects whose handles are not hidden from the current figure so, you can avoid using clf in the code snippet.
See if this example offers some idea on how to do:
[X,Y] = meshgrid(linspace(-15, 15, 50));
fcn = @(x,y,k) k*x.^2 + y.^2;
v = [1:-0.05:-1; -1:0.05:1];
for k1 = 1:2
for k2 = v(k1,:)
surfc(X, Y, fcn(X,Y,k2))
axis([-15 15 -15 15 -300 500])
drawnow
pause(0.1)
end
end
Hope this helps !

카테고리

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