This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Mesh, Submesh

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.

Value Summary

MeshLibrary wrapper for “UMesh, VMesh, XMesh, YMesh, and ZMeshSee below
SubmeshLibrary wrapper for “USubmesh, VSubmesh, XSubmesh, and YSubmeshSee below

Graphics Primitives

ObjectsDefault Values
plot::Cylindrical, plot::Function3d, plot::Spherical, plot::Surface, plot::XRotate, plot::ZRotate

Mesh: [25, 25]

Submesh: [0, 0]


Mesh: 51


Mesh: 25

Submesh: 4

plot::Curve2d, plot::Curve3d, plot::Function2d, plot::Polar

Mesh: 121

Submesh: 0


Mesh: [11, 11]

Submesh: [0, 0]


Mesh: [15, 15]

plot::Implicit2d, plot::Raster, plot::VectorField2d

Mesh: [11, 11]


Mesh: [7, 7, 7]


Mesh: [11, 11, 11]


Mesh: [256, 256]


Mesh: [25, 25]


Mesh: [60, 11]

Submesh: [0, 1]


Submesh: [2, 2]

plot::Ode2d, plot::Ode3d

Submesh: 4


Submesh: 6


The attributes Mesh and Submesh determine the number of sample points used for the numerical approximation of plot objects.

Many plot objects have to be evaluated numerically on a discrete mesh. Depending on the object type, there are type specific attributes such as XMesh (for 2D function graphs), UMesh, VMesh (for parametrized surfaces), XMesh, YMesh, ZMesh (for implicit plots in 3D) etc. setting the number of sample points of the numerical mesh.

The 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 Mesh must be integer numbers or lists of such numbers. The more specific attributes are set automatically when Mesh values are specified.

E.g., in a 2D function plot of type plot::Function2d, Mesh = 200 is equivalent to XMesh = 200. In a 3D surface plot of type plot::Surface, Mesh = [40, 50] is equivalent to UMesh = 40, VMesh = 50.

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 Mesh attribute.

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.

Like Mesh, the attribute Submesh unifies type specific attributes such as XSubmesh, USubmesh etc. Depending on the object, the values of Submesh have to be integers or lists of integers.

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 XLinesVisible, ULinesVisible etc. The coordinates lines are available only for the mesh given by the “major” mesh points, whereas Submesh does not influence the number of coordinate lines. Thus, increased Mesh values yield a smoother plot with more coordinate lines, whereas Submesh can be used to smoothen the plot without adding further coordinate lines.

Apart from this effect, the pair Mesh = n, Submesh = 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 Mesh and Submesh attributes.


Example 1

In the following plot, the default value of Mesh does 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)):

Example 2

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

Example 3

Note the difference between increased Mesh values and additional sample points inserted via Submesh. Submesh does 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:

See Also

MuPAD Functions

Was this topic helpful?