如何动画这一3D图在Matlab?这一、动画、Matlab

2023-09-08 10:51:09 作者:酒子

我目前的code:

a=7
f=10
T=1/f;
v=40
wl=v/f;
x1=1;
x2=30
step=0.01

t=x1:step:x2;
x=x1:step:x2;
y=a*sind(2*pi*f*(t+(x*T)/wl)); 
h=plot3(x,y,t);
set(h,'EraseMode','xor','MarkerSize',20)
xlabel('displacement(m)');
ylabel('amplitude(m)');
title('Wave Animation');
for t=x1:step:x2
drawnow
y=a*sind(2*pi*f*(t+(x*T)/wl)); 
set(h,'YData',y)
pause(0.01)
end

我将其转换为3D网格的情节,但它需要年龄在动画渲染和Matlab崩溃。

I converted it to a 3D mesh plot but it takes ages to render in animation and Matlab crashes.

a=7
f=10
T=1/f;
v=40
wl=v/f;
x1=1;
x2=30
step=0.01

t=x1:step:x2;
x=x1:step:x2;
[x,t] = meshgrid(x,t);
y     = a*sind(2*pi*f*(t+(x*T)/wl)); 
mesh(y)

什么是动画是最好的方法做之前,以使它看起来类似于我有3D?

What's the best way to animate this so that it looks similar to what I have before making it 3D ?

推荐答案

如果您不能实时动画这一点,一个简单的方法是使用的的getFrame 和的电影。您可以使用的getFrame 来捕捉帧画面,在任何速度可以生成它们,然后用电影重播帧以更快帧速率。请参阅的getFrame 链接,一个简单的例子。

If you can't animate this in real time, an easy alternative is using getframe and movie. You use getframe to capture frames at whatever rate you can generate them, then use movie to replay the frames at a faster frame rate. See the getframe link for a simple example.