| Contents | Index |
plot::Function3d creates the 3D graph of a function in 2 variables.
Calls:
plot::Function3d(f, Options)
plot::Function3d(f, x =
..
, y =
..
, <a = amin .. amax>, Options)
Parameters:
|
f: |
the function: an arithmetical expression or a piecewise object in the independent variables |
|
x: |
the first independent variable: an identifier or an indexed identifier. |
|
|
the plot range in |
|
y: |
the second independent variable: an identifier or an indexed identifier. |
|
|
the plot range in |
See Also:
plot, plot::copy, plot::Function2d, plot::Surface, plotfunc2d, plotfunc3d
Details:
The expression f(x, y) is evaluated at finitely many points
,
in the plot range. There may be singularities. Although a heuristics is used to find a reasonable
range when singularities are present, it is highly recommended to specify a
range via ViewingBoxZRange =
with suitable numerical real values
,
. Cf. example 2.
Animations are triggered by specifying a range
for a parameter a that is different from the indedependent variables x, y. Thus, in animations, the
-range
, the
-range
as well as the animation range
must be specified. Cf. example 3.
The function f is evaluated on a regular equidistant mesh of sample points determined by the attributes XMesh and YMesh (or the shorthand-notation for both, Mesh). By default, the attribute AdaptiveMesh = 0 is set, i.e., no adaptive refinement of the equidistant mesh is used.
If the standard mesh does not suffice to produce a sufficiently detailed plot, one may either increase the value of XMesh and YMesh or set AdaptiveMesh = n with some (small) positive integer n. This may result in up to
times as many triangles as used with AdaptiveMesh = 0, potentially more when f has non-isolated singularities. Cf. example 4.
The “coordinate lines” (“parameter lines”) are curves on the function graph.
The phrase “XLines” refers to the curves
with the parameter
running from
to
, while
is some fixed value from the interval
.
The phrase “YLines” refers to the curves
with the parameter
running from ymin to ymax, while
is some fixed value from the interval
.
By default, the parameter lines are visible. They may be “switched off” by specifying XLinesVisible = FALSE and YLinesVisible = FALSE, respectively.
The coordinate lines controlled by XLinesVisible = TRUE/FALSE and YLinesVisible = TRUE/FALSE indicate the equidistant regular mesh set via the Mesh attributes. If the mesh is refined by the Submesh attributes or by the adaptive mechanism controlled by AdaptiveMesh = n, no additional parameter lines are drawn.
As far as the numerical approximation of the function graph is concerned, the settings
, ![]()
and
, Submesh = [0, 0]
are equivalent. However, in the first setting, nx parameter lines are visible in the
direction, while in the latter setting
parameter lines are visible. Cf. example 5.
Example 1
The following call returns an object representing the graph of the function
over the region
,
:
g := plot::Function3d(sin(x^2 + y^2), x = -2..2, y = -2..2)
![]()
Call plot to plot the graph:
plot(g)

Functions can also be specified by piecewise objects or procedures:
f := piecewise([x < y, 0], [x >= y, (x - y)^2]):
plot(plot::Function3d(f, x = -2 .. 4, y = -1 .. 3))

f := proc(x, y)
begin
if x + y^2 + 2*y < 0 then
0
else
x + y^2 + 2*y
end_if:
end_proc:
plot(plot::Function3d(f, x = -3 .. 2, y = -2 .. 2))

delete g, f
Example 2
We plot a function with singularities:
f := plot::Function3d(x/y + y/x, x = -1 .. 1, y = - 1 .. 1):
plot(f)

We specify an explicit viewing range for the
direction:
plot(f, ViewingBoxZRange = -20 .. 20)

delete f
Example 3
We generate an animation of a parametrized function:
plot(plot::Function3d(sin((x - a)^2 + y^2),
x = -2 .. 2, y = -2 .. 2, a = 0 .. 5))


Example 4
The standard mesh for the numerical evaluation of a function graph does not suffice to generate a satisfying graphics in the following case:
plot(plot::Function3d(besselJ(0, sqrt(x^2 + y^2)),
x = -20 .. 20, y = -20 .. 20))

We increase the number of mesh points. Here, we use XSubmesh and YSubmesh to place 2 additional points in each direction between each pair of neighboring points of the default mesh. This increases the runtime by a factor of
:
plot(plot::Function3d(besselJ(0, sqrt(x^2 + y^2)),
x = -20 .. 20, y = -20 .. 20,
Submesh = [2, 2]))

Alternatively, we enable adaptive sampling by setting the value of AdaptiveMesh to some positive value:
plot(plot::Function3d(besselJ(0, sqrt(x^2 + y^2)),
x = -20 .. 20, y = -20 .. 20,
AdaptiveMesh = 2))

Example 5
By default, the parameter lines of a function graph are “switched on”:
plot(plot::Function3d(x^2 + y^2, x = 0 .. 1, y = 0 .. 1))

The parameter lines are “switched off” by setting XLinesVisible, YLinesVisible:
plot(plot::Function3d(x^2 + y^2, x = 0 .. 1, y = 0 .. 1,
XLinesVisible = FALSE,
YLinesVisible = FALSE))

The number of parameter lines are determined by the Mesh attributes:
plot(plot::Function3d(x^2 + y^2, x = 0 .. 1, y = 0 .. 1,
Mesh = [5, 12]))

When the mesh is refined via the Submesh attributes, the numerical approximation of the surface becomes smoother. However, the number of parameter lines is not increased:
plot(plot::Function3d(x^2 + y^2, x = 0 .. 1, y = 0 .. 1,
Mesh = [5, 12],
XSubmesh = 1, YSubmesh = 2))

Example 6
Functions need not be defined over the whole parameter range:
plot(plot::Function3d(sqrt(1-x^2-y^2), x=-1..1, y=-1..1))

plot(plot::Function3d(sqrt(sin(x)+cos(y))))

This makes for an easy way of plotting a function over a non-rectangular area:
chi := piecewise([x^2 < abs(y), 1])
![]()
plot(plot::Function3d(chi*sin(x+cos(y))),
CameraDirection=[-1,0,0.5])


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 |