Skip to Main Content Skip to Search
Product Documentation

plot::Streamlines2dstreamlines of vector fields

plot::Streamlines2d([v_1, v_2], x = `x_{min}`..`x_{max}`, y = `y_{min}`..`y_{max}`) creates streamlines of the vector field defined by (x, y) -> (v[1](x, y), v[2](x, y)) with (x, y) in [x[min], x[max]] x [y[min], y[max]].

→ Examples

Calls:

plot::Streamlines2d([v1, v2], x = `x_{min}` .. `x_{max}`, y = `y_{min}` .. `y_{max}`, <a = amin .. amax>, Options)

plot::Streamlines2d(v1, v2, x = `x_{min}` .. `x_{max}`, y = `y_{min}` .. `y_{max}`, <a = amin .. amax>, Options)

plot::Streamlines2d(V, x = `x_{min}` .. `x_{max}`, y = `y_{min}` .. `y_{max}`, <a = amin .. amax>, Options)

Parameters:

v1, v2

the x- and y-component of the vector field: arithmetical expressions in x, y, and, possibly, the animation parameter a
v1, v2 are equivalent to the attributes XFunction, YFunction.

V

a matrix of category Cat::Matrix with two entries that provide the components v1, v2 of the vector field.

x, y

identifiers.
x, y are equivalent to the attributes XName, YName.

`x_{min}` .. `x_{max}`, `y_{min}` .. `y_{max}`

real numerical values.
`x_{min}` .. `x_{max}`, `y_{min}` .. `y_{max}` are equivalent to the attributes XRange, YRange, XMin, XMax, YMin, YMax.

See Also:

plot, plot::copy, plot::Ode2d, plot::Ode3d, plot::VectorField2d, plot::VectorField3d

Details:

Example 1

plot::Streamlines2d depicts vector fields by (more or less) equidistant stream lines:

plot(plot::Streamlines2d(-x, -y, x=-2..2, y=-2..2))

MuPAD graphics

Note that this style of display necessarily breaks symmetries, in this case the perfect rotational symmetry of the vector field.

Additionally, cycles will not be closed, but leave a gap:

plot(plot::Streamlines2d(-y, x, x=-2..2, y=-2..2))

MuPAD graphics

Example 2

Apart from the “usual” parameters such as parameter ranges, line color, or line width, plot::Streamlines2d can be controlled with the attribute MinimumDistance, which sets the minimum distance between stream lines:

plot(plot::Streamlines2d(sin(x^2+y^2), cos(x^2+y^2),
                         x = -3..3, y = -2..2))

MuPAD graphics

plot(plot::Streamlines2d(sin(x^2+y^2), cos(x^2+y^2),
                         x = -3..3, y = -2..2,
                         MinimumDistance = 0.2))

MuPAD graphics

plot(plot::Streamlines2d(sin(x^2+y^2), cos(x^2+y^2),
                         x = -3..3, y = -2..2,
                         MinimumDistance = 0.05))

MuPAD graphics

Example 3

A line color function for plot::Streamlines2d has access to the current coordinates, to the components of the vector field at the current point, to the current length on the curve (both in terms of the “time” parameter and Euclidean distance) and an integer count of the current curve (which are not found in some predefined order). We use the curve number to generate a colorful display:

num2col := (x, y, vx, vy, t, l, n) -> RGB::fromHSV([111*n, 1, 1]):
plot(plot::Streamlines2d(sin(x^2+y^2), cos(x^2+y^2),
                         x = -3..3, y = -2..2,
                         LineColorFunction = num2col))

MuPAD graphics

Using the curve length information allows us to include directional information in the visual display:

l2col := (x, y, vx, vy, t, l) -> [frac(5*l) $ 3]:
plot(plot::Streamlines2d(sin(x^2+y^2), cos(x^2+y^2),
                         x = -3..3, y = -2..2,
                         LineWidth = 0.75,
                         LineColorFunction = l2col))

MuPAD graphics

Often, an easier way of plotting the orientation of the stream lines is to activate the arrow heads plot::Streamlines2d plots at the middle of each sufficiently long) stream line. These are made invisible by the default tip length of 0:

plot(plot::Streamlines2d(0.3*x-y, 0.3*y+x,
                         x = -3..3, y = -2..2,
                         TipLength = 3*unit::mm))

MuPAD graphics

Example 4

Since the placement of stream lines is hard to predict, plot::Streamlines2d is not really suitable for animations. It is possible to animate plot::Streamlines2d, but coherence between the animation frames is less than usual:

plot(plot::Streamlines2d(sin(x^2+y^2), cos(x^2-y^2+a),
                         x = -2..2, y = -2..2, a = -PI..PI,
                         MinimumDistance = 0.1,
                         Frames=10))

MuPAD graphicsimage

Example 5

With the default settings, plot::Streamlines2d is not able to plot the vector field [1, 3^(2/y)] (which is not Lipschitz continous) in a satisfying way:

plot(plot::Streamlines2d([1, surd(3,y)^2],
                         x=-3..3, y=-2..2))

MuPAD graphics

By using a different numerical integrator, the problems can be overcome (at the cost of longer computation):

plot(plot::Streamlines2d([1, surd(3,y)^2],
                         x=-3..3, y=-2..2,
                         ODEMethod=RKF43,
                         RelativeError=1e-3))

MuPAD graphics

Background:

The algorithm used in plot::Streamlines2d has been published in “Creating Evenly-Spaced Streamlines of Arbitrary Density” by Bruno Jobard and Wilfrid Lefer at the Eurographics Workshop in Boulogne-sur-Mer, France.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS