# `plot`::`VectorField3d`

3D vector field

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```plot::VectorField3d(`[v1, v2, v3]`, `x = xmin .. xmax`, `y = ymin .. ymax`, `z = zmin .. zmax`, <`a = amin .. amax`>, `options`)
plot::VectorField3d(`v1`, `v2`, `v3`, `x = xmin .. xmax`, `y = ymin .. ymax`, `z = zmin .. zmax`, <`a = amin .. amax`>, `options`)
```

## Description

```plot::VectorField3d([v_1, v_2, v_3], x = `x_{min}`..`x_{max}`, y = `y_{min}`..`y_{max}`, z = `z_{min}`..`z_{max}`)``` represents a plot of the vector field defined by

with (x, y, z) ∈ [xmin, xmax] ×[ymin, ymax] ×[zmin, zmax].

A vector field is defined by a function . `plot::VectorField3d` displays a vector field by placing arrows at regular intervals with the arrow at (x, y, z) pointing in the direction f(x, y, z).

The length of the arrows depend on |f(x, y, z)| and the setting of the attribute `ArrowLength`: By default, arrow lengths are proportional to the magnitude of f, but can be set to be of fixed length or to scale logarithmically.

The density of arrows placed can be controlled with the attributes `XMesh`, `YMesh`, `ZMesh`, and `Mesh`. See the examples below.

## Attributes

AttributePurposeDefault Value
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`ArrowLength`scaling of arrows in a vector field`Proportional`
`Color`the main color`RGB::Blue`
`Frames`the number of frames in an animation`50`
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`LineColor`color of lines`RGB::Blue`
`LineWidth`width of lines`0.1`
`LineColor2`color of lines`RGB::DeepPink`
`LineColorType`line coloring types`Flat`
`LineColorFunction`functional line coloring
`LineColorDirection`the direction of color transitions on lines[`0`, `0`, `1`]
`LineColorDirectionX`x-component of the direction of color transitions on lines`0`
`LineColorDirectionY`y-component of the direction of color transitions on lines`0`
`LineColorDirectionZ`z-component of the direction of color transitions on lines`1`
`Mesh`number of sample points[`7`, `7`, `7`]
`Name`the name of a plot object (for browser and legend)
`ParameterEnd`end value of the animation parameter
`ParameterName`name of the animation parameter
`ParameterBegin`initial value of the animation parameter
`ParameterRange`range of the animation parameter
`PointSize`the size of points`1.5`
`PointStyle`the presentation style of points`FilledCircles`
`PointsVisible`visibility of mesh points`TRUE`
`TimeEnd`end time of the animation`10.0`
`TimeBegin`start time of the animation`0.0`
`TimeRange`the real time span of an animation`0.0` .. `10.0`
`Title`object title
`TitleFont`font of object titles[`" sans-serif "`, `11`]
`TitlePosition`position of object titles
`TitleAlignment`horizontal alignment of titles w.r.t. their coordinates`Center`
`TitlePositionX`position of object titles, x component
`TitlePositionY`position of object titles, y component
`TitlePositionZ`position of object titles, z component
`Visible`visibility`TRUE`
`VisibleAfter`object visible after this time value
`VisibleBefore`object visible until this time value
`VisibleFromTo`object visible during this time range
`VisibleAfterEnd`object visible after its animation time ended?`TRUE`
`VisibleBeforeBegin`object visible before its animation time starts?`TRUE`
`XFunction`function for x values
`XMax`final value of parameter “x”
`XMesh`number of sample points for parameter “x”`7`
`XMin`initial value of parameter “x”
`XName`name of parameter “x”
`XRange`range of parameter “x”
`YFunction`function for y values
`YMax`final value of parameter “y”
`YMesh`number of sample points for parameter “y”`7`
`YMin`initial value of parameter “y”
`YName`name of parameter “y”
`YRange`range of parameter “y”
`ZFunction`function for z values
`ZMax`final value of parameter “z”
`ZMesh`number of sample points for parameter “z”`7`
`ZMin`initial value of parameter “z”
`ZName`name of parameter “z”
`ZRange`range of parameter “z”

## Examples

### Example 1

We demonstrate a plot of the vector field v(x, y, z) = (1, sin(x) + cos(y), sin(z)):

```field := plot::VectorField3d([1, sin(x) + cos(y), sin(z)], x = 0..6, y = 0..2.5, z = 0..5, Mesh = [7, 7, 7]): plot(field):```

`delete field:`

### Example 2

Like most other objects, `plot::VectorField3d` can be animated by supplying an extra parameter:

```mycolor := (x, y, z, vx, vy, vz, a) -> [a, a*z, 1 - a]: field := plot::VectorField3d([ a*y + (1-a)*x , -a*x + (1-a)*y, a*sin(PI*z)], x = -1..1, y = -1..1, z = 0..1, LineColorFunction = mycolor, Mesh = [7, 7, 7], a = 0..1): text := plot::Text3d(a -> "a = ".stringlib::formatf(a, 2, 5), [1, 0.7, 1.2], a = 0..1): plot(field, text, Axes = Frame)```

`delete field, text:`

## Parameters

 `v1`, `v2`, `v3` The x-, y-, and z-component of the vector field: arithmetical expressions in `x`, `y`, `z` and, possibly, the animation parameter `a`. `v1`, `v2`, `v3` are equivalent to the attributes `XFunction`, `YFunction`, `ZFunction`. `x`, `y`, `z` Identifiers. `x`, `y`, `z` are equivalent to the attributes `XName`, `YName`, `ZName`. `xmin .. xmax`, `ymin .. ymax`, `zmin .. zmax` Real numerical values. `xmin` .. `xmax`, `ymin` .. `ymax`, `zmin` .. `zmax` are equivalent to the attributes `XRange`, `YRange`, `ZRange`, `XMin`, `XMax`, `YMin`, `YMax`, `ZMin`, `ZMax`. `a` Animation parameter, specified as `a```` = amin..amax```, where `amin` is the initial parameter value, and `amax` is the final parameter value.