【问题标题】:Animating stream particles in MATLAB在 MATLAB 中动画流粒子
【发布时间】:2014-08-15 12:47:11
【问题描述】:

我最近一直在玩 MATLAB 中的动画流。

虽然我设法使以下工作正常,但我想知道是否有一种方法可以不断地从起始位置播种新粒子,即当一个粒子离开视图时,一个新粒子可以出现在起始位置。

% Node points
x = 0:100;
y = 0:100;

% Grid of all points
[X,Y] = meshgrid(x, y);

% Coefficients for Velocity field
K = 10;
C = 10;

% Velocity vector calcs (wavy example flow)
Vx = K + C * sin(x);
Vy = (K/2) + (C/2) * cos(y);

% Grid of velocity vectors
[VX,VY] = meshgrid(Vx, Vy);

% Plots the velocity streamslice
streamslice(X, Y, VX, VY);

% Starting points for the particles
Sx = 0;
Sy = 0:20:100;

% Grid of starting points
[SX,SY] = meshgrid(Sx, Sy);

% stream2 computes 2D streamline data
vertices = stream2(X, Y, VX ,VY, SX, SY);

% Interpolates stream line velocities
iverts = interpstreamspeed(X, Y, VX, VY, vertices, 0.05);

% Adds animated stream particles
streamparticles(iverts,1,'Animate',100,...
    'ParticleAlignment','on',...
    'MarkerFaceColor','red',...
    'Marker','o');

编辑:后续问题:如果我想绘制随时间变化的瞬态速度,这会简单地绘制在一个循环中,还是这种动画不起作用,因为 streamparticles 函数不知道粒子在哪里是上一个时间步长吗?

谢谢

【问题讨论】:

    标签: matlab particles


    【解决方案1】:

    为了从起始位置连续播种新粒子,请尝试增加 streamparticles 函数中 'iverts' 之后的第一个数字:

    例如%添加动画流粒子 streamparticles(ivets,5,'Animate',100,... 'ParticleAlignment','on',... 'MarkerFaceColor','红色',... '标记','o');

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多