简体   繁体   English

MATLAB-3D动画图

[英]MATLAB - 3D Animation plot

I have a matrix with 4 variables. 我有一个包含4个变量的矩阵。 I want to plot the results as a 3D surface animation, having 3 of the variables as x,y and z and the 4th variable as time (t). 我想将结果绘制为3D曲面动画,其中3个变量分别为x,y和z,第4个变量为时间(t)。

I imagine the code to be something like: 我想象代码是这样的:

figure(1)
plot4d(Results(:,1), Results(:,2), Results(:,6), Results(:,3))

Here is some sample data: 以下是一些示例数据:

    X         Y         t                            Z                     

   -0.1111    1.2670    1.1000    0.0000    0.0000   9.4568
   -0.1111    1.2670    1.2000    0.0000    0.0000   15.9115
   -0.1111    1.2670    1.3000    0.0000    0.0000   18.3639
   -0.1111    1.2670    1.4000    0.0000    0.0000   22.3732
   -0.1111    1.2670    1.5000    0.0000    0.0000   23.3274
   -0.1111    1.2670    1.6000    0.0000    0.0000   23.3389
   -0.1111    1.2670    1.7000    0.0000    0.0000   23.3437
   -0.1111    1.2670    1.8000    0.0000    0.0000   22.0600
   -0.1111    1.2670    1.9000    0.0000    0.0000   23.7531
   -0.1111    1.2670    1.0000    0.0000    0.0000         0
   -0.1111    1.2670    2.1000    0.0000    0.0000         0
   -0.1111    1.2670    2.2000    0.0000    0.0000         0
   -0.1111    1.2670    2.3000    0.0000    0.0000         0
   -0.1111    1.2670    2.4000    0.0000    0.0000         0
   -0.1111    1.2670    2.5000    0.0000    0.0000         0
   -0.1111    1.2670    2.0000    0.0000    0.0000   23.1249
   -0.1111    1.5330    1.1000    0.0000    0.0000   20.7103
   -0.1111    1.5330    1.2000    0.0000    0.0000   40.2953
   -0.1111    1.5330    1.3000    0.0000    0.0000   53.0801
   -0.1111    1.5330    1.4000    0.0000    0.0000   63.1132

The goal is to produce a 3D surface plot that varies with time, so that it looks like someone is waving a blanket ;) 目标是生成随时间变化的3D表面图,以便看起来有人在挥舞毯子;)

If what you plot is a line, then you could just display it frame by frame, pausing between them according to the time stamp (assumed to be in seconds): 如果您要绘制的是一条线,则可以将其逐帧显示,并根据时间戳(假定以秒为单位)在它们之间暂停:

 x = Results(:,1);
 y = Results(:,2);
 z = Results(:,3);
 t = Results(:,4);
dt = [diff(t);eps]; 

h = axes('Parent', figure());
hold(h, 'off');

for k = 1:numel(t)
        plot3(h, x(1:k), y(1:k), z(1:k), '-*k');
        pause(dt(k));
end;

If you want to capture the animation for the movie, check the MATLAB tutorial page . 如果要捕获电影的动画,请查看MATLAB教程页面

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM