Main Content

streamslice

Plot streamlines in slice planes

  • Cartesian grid with plotted lines and arrows

Description

example

streamslice(X,Y,Z,U,V,W,xslice,yslice,zslice)draws automatically spaced streamlines from 3-D vector dataU, V, and W. Specify X,Y, and Z as the coordinate data. Specify xslice, yslice, and zslice as the slice locations orthogonal to a particular axis.

streamslice(U,V,W,xslice,yslice,zslice)uses the default coordinate data for U,V, andW. The (x,y,z) location for each element in U,V, andW基于列、行and page index, respectively.

example

streamslice(X,Y,U,V)draws automatically spaced streamlines from 2-D vector data Uand V. SpecifyXandYas the coordinate data.

example

streamslice(U,V)uses the default coordinate data for UandV. The (x,y) location for each element in UandVis based on the column and row index, respectively.

example

streamslice(___,arrowsmode), wherearrowsmodeis'noarrows', does not draw direction arrows. The default forarrowsmodeis'arrows', which draws direction arrows. Use this option with any of the input arguments from the previous syntaxes.

example

streamslice(___,density) modifies the automatic spacing of the streamlines, where densityis a positive scalar. The default value is 1. Higher values produce more streamlines on each plane. For example, 2 produces approximately twice as many streamlines as the default, while 0.5 produces approximately half as many.

streamslice(___,method)specifies the interpolation method, where method can be 'linear', 'cubic', or 'nearest'.

streamslice(ax,___)plots into the specified axes, instead of into the current axes object (gca).

example

lineobj= streamslice(___)returns theLineobjects created.

example

[verts,averts] = streamslice(___)returns vertices for drawing the streamlines and arrows as cell arrays. This syntax does not plot the streamlines.

Examples

collapse all

Load thewinddataset, which loads the 3-D arraysu,v,w,x,y, andz, representing air currents over regions of North America. Draw streamlines along the slice plane wherez = 5.

loadwindstreamslice(x,y,z,u,v,w,[],[],5) axistight

Figure contains an axes object. The axes object contains 94 objects of type line.

Load thewinddataset and draw streamlines without direction arrows along the slice plane wherez = 5.

loadwindstreamslice(x,y,z,u,v,w,[],[],5,'noarrows') axistight

Figure contains an axes object. The axes object contains 45 objects of type line.

Load thewinddataset and draw streamlines along the slice plane, wherez = 5. Use adensityvalue of2to draw approximately twice as many streamlines as the default.

loadwindstreamslice(x,y,z,u,v,w,[],[],5,2) axistight

Figure contains an axes object. The axes object contains 175 objects of type line.

Load thewinddataset and compute the vertices of streamlines along the slice planes, wherez = 1, 5, and 10.

loadwind[verts, ~] = streamslice(x,y,z,u,v,w,[],[],[1,5,10]);

Pass the vertices tostreamtubeto visualize the lines as tubes.

streamtube(verts,1) view(3) axistightshadinginterpcamlight lightinggouraud

Figure contains an axes object. The axes object contains 161 objects of type surface.

Plot streamlines and store the returnedLineobjects inl.

[x,y] = meshgrid(-10:10); u = 2.*x.*y; v = y.^2 - x.^2; l = streamslice(x,y,u,v); axistight

Figure contains an axes object. The axes object contains 112 objects of type line.

Set the line width of the streamlines to 2. Set their color to red. Use thesetfunction to change the properties of all the streamlines at the same time.

set(l,'LineWidth',2) set(l,'Color','r');

Figure contains an axes object. The axes object contains 112 objects of type line.

First, create a surface plot.

z = peaks; surf(z); shadinginterp;

Figure contains an axes object. The axes object contains an object of type surface.

Compute the two-dimensional gradient ofz. Use thexandycomponents as the vector data input forstreamslice. Set the color of the streamlines to black.

[u,v] = gradient(z); l = streamslice(u,v); set(l,'Color','k');

Figure contains an axes object. The axes object contains 153 objects of type surface, line.

Displace the streamlines on thez-axis so that they are drawn on the surface of the curve.

fori=1:length(l) zi = interp2(z,l(i).XData, l(i).YData); l(i).ZData = zi;end

Figure contains an axes object. The axes object contains 153 objects of type surface, line.

Input Arguments

collapse all

x-axis coordinate data, specified as a 2-D or 3-D array. It must be monotonic, but does not need to be uniformly spaced.

X,Y,Z,U,V, andWmust be the same size.

You can use themeshgridfunction to createX,Y, andZmatrices.

y-axis coordinate data, specified as a 2-D or 3-D array. It must be monotonic, but does not need to be uniformly spaced.

X,Y,Z,U,V, andWmust be the same size.

You can use themeshgridfunction to createX,Y, andZmatrices.

z-axis coordinate data, specified as a 3-D array. It must be monotonic, but does not need to be uniformly spaced.

X,Y,Z,U,V, andWmust be the same size.

You can use themeshgridfunction to createX,Y, andZmatrices.

x-components of vector data, specified as a 2-D or 3-D array.

X,Y,Z,U,V, andWmust be the same size.

y-components of vector data, specified as a 2-D or 3-D array.

X,Y,Z,U,V, andWmust be the same size.

z-components of vector data, specified as a 3-D array.

X,Y,Z,U,V, andWmust be the same size.

x-axis slice values, specified in one of these forms:

  • Scalar — Draw one slice plane orthogonal to the x-axis at the specified location.

  • Vector — Draw multiple slice planes orthogonal to the x-axis at the specified locations.

  • [] — Do not draw any slice planes.

y-axis slice values, specified in one of these forms:

  • Scalar — Draw one slice plane orthogonal to the y-axis at the specified location.

  • Vector — Draw multiple slice planes orthogonal to the y-axis at the specified locations.

  • [] — Do not draw any slice planes.

z-axis slice values, specified in one of these forms:

  • Scalar — Draw one slice plane orthogonal to the z-axis at the specified location.

  • Vector — Draw multiple slice planes orthogonal to the z-axis at the specified locations.

  • [] — Do not draw any slice planes.

Streamline density, specified as a positive scalar.

The default value is1. Higher values produce more streamlines on each plane. For example, 2 produces approximately twice as many streamlines as the default, while 0.5 produces approximately half as many.

Arrow display mode, specified as one of these values:

  • 'arrows' — Draw direction arrows on the streamlines.

  • 'noarrows' — Do not draw direction arrows on the streamlines.

Interpolation method, specified as one of these values:

  • 'linear' — Linear interpolation of the values at neighboring grid points in each respective dimension.

  • 'cubic' — Cubic interpolation of the values at neighboring grid points in each respective dimension.

  • 'nearest' — Nearest grid point value.

Target axes, specified as anAxesobject. If you do not specify the axes, thenstreamsliceplots into the current axes.

Output Arguments

collapse all

Lineobjects for streamlines and direction arrows, returned as an array.

Streamline vertices, returned as a cell array. Each element of the cell array is a matrix of vertices for one line.

You can pass these values to any of the streamline drawing functions (streamline, streamribbon, streamtube).

Arrow vertices, returned as a cell array. Each element of the cell array is a matrix of vertices for one arrow. Ifarrowsmodeis'noarrows', averts is an empty cell array.

You can pass these values tostreamline.

Extended Capabilities

Version History

Introduced before R2006a