3-D Visualization Previous page   Next Page

Displaying Divergence with Stream Tubes

Stream tubes are similar to stream lines, except the tubes have width, providing another dimension that you can use to represent information.

By default, MATLAB indicates the divergence of the vector field by the width of the tube. You can also define widths for each tube vertex and thereby map other data to width.

This example uses the following techniques:

Inputs include the coordinates of the volume, vector field components, and starting locations for the stream tubes.

1. Load Data and Calculate Required Values

The first step is to load the data and calculate values needed to make the plots. These values include

2. Draw the Slice Planes

Draw the slice planes (slice) and set surface properties to create a smoothly colored slice. Use 16 colors from the hsv colormap.

3. Add Contour Lines to Slice Planes

Add contour lines (contourslice) to the slice planes. Adjust the contour interval so the lines match the color boundaries in the slice planes:

4. Create the Stream Tubes

Use meshgrid to create arrays for the starting points for the stream tubes, which begin at the minimum x value, range from 20 to 50 in y, and lie in a single plane in z (corresponding to one of the slice planes).

The stream tubes (streamtube) are drawn at the specified locations and scaled to be 1.25 times the default width to emphasize the variation in divergence (width). The second element in the vector [1.25 30] specifies the number of points along the circumference of the tube (the default is 20). You might want to increase this value as the tube size increases, to maintain a smooth-looking tube.

Set the data aspect ratio (daspect) before calling streamtube.

Stream tubes are surface objects, therefore you can control their appearance by setting surface properties. This example sets surface properties to give a brightly lit, red surface.

5. Define the View

The final step is to define the view and add lighting (view, axis volumebounds, Projection, camlight).


Previous page  Displaying Curl with Stream Ribbons Creating Stream Particle Animations Next page

© 1994-2005 The MathWorks, Inc.