| Contents | Index |
plot::Streamlines2d(
, x =
, y =
) creates streamlines of the vector field defined by
with
.
Calls:
plot::Streamlines2d([v1, v2], x =
..
, y =
..
, <a = amin .. amax>, Options)
plot::Streamlines2d(v1, v2, x =
..
, y =
..
, <a = amin .. amax>, Options)
plot::Streamlines2d(V, x =
..
, y =
..
, <a = amin .. amax>, Options)
Parameters:
|
v1, v2: |
the |
|
V: |
a matrix of category Cat::Matrix with two entries that provide the components v1, v2 of the vector field. |
|
x, y: |
identifiers. |
|
|
real numerical values. |
See Also:
plot, plot::copy, plot::Ode2d, plot::Ode3d, plot::VectorField2d, plot::VectorField3d
Details:
A vector field is defined by a function
. plot::Streamlines2d displays a vector field by drawing almost evenly spaced streamlines of the vector field, i.e., curves to which the vector field is tangential at every point. The density of stream lines (and the time needed for calculation) is controlled with the attribute MinimumDistance.
As a rule of thumb: decreasing the value of MinimumDistance by a factor of 2 leads to an increase of the runtime by a factor of 4.
A user defined color scheme may be specified by LineColorFunction = color, where color is a MuPAD® procedure accepting 6 input parameters and returning a list of RGB values. During plotting, this function is called in the form
:
The values x, y are the coordinates of the current point.
The values v1, v2 are the components of the vector field at the current point.
The value t is the “time” of the current point (x, y) on the current streamline. The scaling of this parameter depends on the vector field.
The value l is the curve length of the current streamline from its starting point the current point (x, y), as a Euclidean distance. This parameter is invariant with respect to scalar changes of the vector field (up to changing the direction of the streamline).
The integer value n is a count of the current streamline. Each separate streamline has a different value.
Cf. example 3.
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))

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))

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))

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

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

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))

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))

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
:
plot(plot::Streamlines2d(0.3*x-y, 0.3*y+x,
x = -3..3, y = -2..2,
TipLength = 3*unit::mm))

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))


Example 5
With the default settings, plot::Streamlines2d is not able to plot the vector field
(which is not Lipschitz continous) in a satisfying way:
plot(plot::Streamlines2d([1, surd(3,y)^2],
x=-3..3, y=-2..2))

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))

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.

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 |