Main Content

stream2

Compute 2-D streamline data

Description

example

XY = stream2(X,Y,U,V,startX,startY) returns streamline data as a 2-D matrix of vector fields. The inputs x and y are vector data coordinates, U and V are vector data, and startX and startY are the starting positions of the streamlines.

XY = stream2(U,V,startX,startY) uses the default coordinate data for U and V. The (x,y) location for each element in U and V is based on the column and row index, respectively.

example

XY = stream2(___,options) computes 2-D streamline data using the specified options, defined as a one- or two-element vector with the form step or [step maxvert], where step is the step size in data units for interpolating the vector data and maxvert is the maximum number of vertices in a streamline. Use this argument with any of the input argument combinations from the previous syntaxes.

Examples

collapse all

Load the wind data set, which contains measurements of air current over regions of North America.

  • 3-D arrays x and y represent the locations of air current measurements.

  • 3-D arrays u and v represent the velocity of the air current in 3-D vector fields.

Use the fifth page of the arrays. Define the starting position of four hypothetical particles. In this case, the four starting locations are (80, 20), (80, 30), (80, 40), and (80, 50).

load wind
x5 = x(:,:,5);
y5 = y(:,:,5);
u5 = u(:,:,5);
v5 = v(:,:,5);
[startX,startY] = meshgrid(80,20:10:50);

Compute the 2-D streamline vertex data for a hypothetical particle placed into the air current with stream2.

verts = stream2(x5,y5,u5,v5,startX,startY);

Visualize the 2-D matrix of vector fields with streamline.

streamline(verts)

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

Load the wind data set, which contains measurements of air current over regions of North America.

  • 3-D arrays x and y represent the locations of air current measurements.

  • 3-D arrays u and v represent the velocity of the air current in 3-D vector fields..

Use the fifth page of the arrays. Define the starting position of four hypothetical particles. In this case, the four starting locations are (80, 20), (80, 30), (80, 40), and (80, 50).

load wind
x5 = x(:,:,5);
y5 = y(:,:,5);
u5 = u(:,:,5);
v5 = v(:,:,5);
[startX,startY] = meshgrid(80,20:10:50);

Decrease the streamline resolution by increasing the step size from the default of 0.1 to 3.

step = 3;

Compute the 2-D streamline vertex data for a hypothetical particle placed into the air current with stream2 and step.

verts = stream2(x5,y5,u5,v5,startX,startY,step);

Visualize the 2-D matrix of vector fields with streamline. The larger step size results in a lower resolution streamline.

streamline(verts)

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

Load the wind data set, which contains measurements of air current over regions of North America.

  • 3-D arrays x and y represent the locations of air current measurements.

  • 3-D arrays u and v represent the velocity of the air current in 3-D vector fields.

Use the fifth page of the arrays. Define the starting position of four hypothetical particles. In this case, the four starting locations are (80, 20), (80, 30), (80, 40), and (80, 50).

load wind
x5 = x(:,:,5);
y5 = y(:,:,5);
u5 = u(:,:,5);
v5 = v(:,:,5);
[startX,startY] = meshgrid(80,20:10:50);

Increase the streamline resolution by decreasing the step size from the default of 0.1 to 0.01.

step = 0.01;

Set the maximum number of vertices so that computation ends after the first 1,000 vertices are calculated.

maxvert = 1000;

Compute the 2-D streamline vertex data for a hypothetical particle placed into the air current with stream2, step, and maxvert.

verts = stream2(x5,y5,u5,v5,startX,startY,[step maxvert]);

Visualize the 2-D matrix of vector fields with streamline. Show the full range of data values by setting the axis limits. The streamlines end after 1,000 vertices are calculated, so the streamlines stop before showing the full range of data.

streamline(verts)
xlim([75 135])
ylim([15 65])

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

Input Arguments

collapse all

x-axis coordinates of vector data, specified as a 2-D array. It must be monotonic, but does not need to be uniformly spaced. X must be the same size as Y, U, and V.

You can use the meshgrid function to create X.

y-axis coordinates of vector data, specified as a 2-D array. It must be monotonic, but does not need to be uniformly spaced. Y must be the same size as X, U, and V.

You can use the meshgrid function to create Y.

x-components of vector data, specified as a 2-D array. U must be the same size as X, Y, and V.

y-components of vector data, specified as a 2-D array. V must be the same size as X, Y, and U.

x-axis streamline starting positions, specified as a vector or matrix. startX must be a scalar or be the same size as startY.

y-axis streamline starting positions, specified as a vector or matrix. startY must be a scalar or be the same size as startX.

Streamline options, specified as a one- or two-element vector with one of the following forms:

  • step

  • [step maxvert]

step is the step size used to adjust the streamline resolution and determine the vertex locations for which streamline velocity is interpolated. maxvert is the maximum number of vertices calculated for a streamline before computation is complete.

The default step-size is 0.1, and the default maximum number of vertices in a streamline is 10,000.

Extended Capabilities

Version History

Introduced before R2006a