This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Compute 2-D streamline data


XY = stream2(x,y,u,v,startx,starty)
XY = stream2(u,v,startx,starty)
XY = stream2(...,options)


XY = stream2(x,y,u,v,startx,starty) computes streamlines from vector data u and v.

The arrays x and y, which define the coordinates for u and v, must be monotonic, but do not need to be uniformly spaced. x and y must have the same number of elements, as if produced by meshgrid.

startx and starty define the starting positions of the streamlines.

The returned value XY contains a cell array of vertex arrays.

XY = stream2(u,v,startx,starty) assumes the arrays x and y are defined as [x,y] = meshgrid(1:n,1:m) where [m,n] = size(u).

XY = stream2(...,options) specifies the options used when creating the streamlines. Define options as a one- or two-element vector containing the step size or the step size and the maximum number of vertices in a streamline:



[stepsize, max_number_vertices]

If you do not specify a value, MATLAB® software uses the default:

  • Step size = 0.1 (one tenth of a cell)

  • Maximum number of vertices = 10000

Use the streamline command to plot the data returned by stream2.


collapse all

Plot 2-D streamlines from data representing air currents over regions of North America.

load wind
[sx,sy] = meshgrid(80,20:10:50);

Extended Capabilities

Introduced before R2006a