Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

Example – Creating Stream Particle Animations

What Particle Animations Can Show

A stream particle animation is useful for visualizing the flow direction and speed of a vector field. The "particles" (represented by any of the line markers) trace the flow along a particular stream line. The speed of each particle in the animation is proportional to the magnitude of the vector field at any given point along the stream line.

1. Specify Starting Points of the Data Range to Plot

This example determines the region of the volume to plot by specifying the appropriate starting points. In this case, the stream plots begin at x = 100 and y spans 20 to 50 in the z = 5 plane, which is not the full volume bounds.

load wind
[sx sy sz] = meshgrid(100,20:2:50,5);

2. Create Stream Lines to Indicate Particle Paths

This example uses stream lines (stream3, streamline) to trace the path of the animated particles, which adds a visual context for the animation.

verts = stream3(x,y,z,u,v,w,sx,sy,sz);
sl = streamline(verts);

3. Define the View

While all the stream lines start in the z = 5 plane, the values of some spiral down to lower values. The following settings provide a clear view of the animation:

4. Calculate the Stream Particle Vertices

Determine the vertices along the stream line where a particle should be drawn. The interpstreamspeed function returns this data based on the stream line vertices and the speed of the vector data. This example scales the velocities by 0.05 to increase the number of interpolated vertices.

Set the axes DrawMode property to fast so the animation will run faster.

The streamparticles function sets the following properties:

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS