| Products & Services | Industries | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
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 define the coordinates for u and v and must be monotonic and 2-D plaid (such as the data produced by meshgrid). startx and starty define the starting positions of the streamlines. The section "Specifying Starting Points for Stream Plots" provides more information on defining starting points.
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]
or
[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.
This example draws 2-D streamlines from data representing air currents over regions of North America.
load wind [sx,sy] = meshgrid(80,20:10:50); streamline(stream2(x(:,:,5),y(:,:,5),u(:,:,5),v(:,:,5),sx,sy));
Volume Visualization for related functions
Specifying Starting Points for Stream Plots for related information
![]() | strcmp, strcmpi | stream3 | ![]() |

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 |