如何动画这一3D图在Matlab? [英] How to animate this 3D plot in Matlab?

查看:297
本文介绍了如何动画这一3D图在Matlab?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前的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.

这篇关于如何动画这一3D图在Matlab?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆