Number of sample points
MuPAD® notebooks are not recommended. 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.
the number of sample points used for the numerical approximation of
Many plot objects have to be evaluated numerically on a discrete
mesh. Depending on the object type, there are type specific attributes
2D function graphs),
VMesh (for parametrized
implicit plots in 3D) etc. setting the number of sample points of
the numerical mesh.
Mesh attribute unifies these more specific
attributes and can be set for all objects that use a discrete numerical
mesh. Depending on the object, the values for
be integer numbers or lists of such numbers. The more specific attributes
are set automatically when
Mesh values are specified.
In the “object inspector” of the interactive graphics
tool (see section Viewer,
Browser, and Inspector: Interactive Manipulation in this document),
only the type specific attributes are visible, not the
Roughly speaking, high
Mesh values yield
smooth plots but cost run time.
With the attribute
Submesh = m, additional m equidistant
sample points are inserted between each pair of adjacent sample points
set by the
Mesh attribute. This smoothens the object.
There is a semantical difference between the “major”
mesh points set by
Mesh and the “minor”
mesh points inserted by
Submesh. There are coordinate
lines associated with the (regular) numerical mesh. See
The coordinates lines are available only for the mesh given by the
“major” mesh points, whereas
not influence the number of coordinate lines. Thus, increased
yield a smoother plot with more coordinate lines, whereas
be used to smoothen the plot without adding further coordinate lines.
Apart from this effect, the pair
Mesh = n,
= m corresponds to the combination
Mesh = (n -
1) (m + 1) + 1,
Submesh = 0.
If adaptive sampling is
enabled, further non-equidistant sample points are chosen automatically
between the equidistant points of the `initial mesh' set via the
In the following plot, the default value of
not suffice to produce a sufficiently exact picture:
plot(plot::Function2d(sin(x^2), x = 0..10)):
A mesh with more sample points yields a higher resolution graphics:
plot(plot::Function2d(sin(x^2), x = 0..10, Mesh = 500)):
The default value of
Mesh does not provide
a sufficient resolution for the following spiral:
plot(plot::Curve2d([x*cos(x), x*sin(x)], x = 0..50*PI)):
The spiral winds around the origin 25 times. We wish to have approximately 40 sample points per revolution, so we need to use a total of 1000 sample points:
plot(plot::Curve2d([x*cos(x), x*sin(x)], x = 0..50*PI, Mesh = 1000)):
Note the difference between increased
and additional sample points inserted via
not introduce additional coordinate lines:
S1 := plot::Scene3d(plot::Function3d( x^2 + y^2, x = 0..1/2, y = 0..1, Mesh = [4, 4])): S2 := plot::Scene3d(plot::Function3d( x^2 + y^2, x = 0..1/2, y = 0..1, Mesh = [4, 4], Submesh = [2, 2])): S3 := plot::Scene3d(plot::Function3d( x^2 + y^2, x = 0..1/2, y = 0..1, Mesh = [10, 10])): plot(S1, S2, S3, Layout = Horizontal, Height = 5*unit::cm, Width = 12*unit::cm, LineColor = RGB::Black):
delete S1, S2, S3: