Documentation

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.

fmesh

Syntax

fmesh(f)
fmesh(f,xyinterval)
fmesh(funx,funy,funz)
fmesh(funx,funy,funz,uvinterval)
fmesh(___,LineSpec)
fmesh(___,Name,Value)
fmesh(ax,___)
fs = fmesh(___)

Description

example

fmesh(f) creates a mesh plot of the expression z = f(x,y) over the default interval [-5 5] for x and y.

example

fmesh(f,xyinterval) plots over the specified interval. To use the same interval for both x and y, specify xyinterval as a two-element vector of the form [min max]. To use different intervals, specify a four-element vector of the form [xmin xmax ymin ymax].

example

fmesh(funx,funy,funz) plots the parametric mesh defined by x = funx(u,v), y = funy(u,v), z = funz(u,v) over the default interval [-5 5] for u and v.

fmesh(funx,funy,funz,uvinterval) plots the parametric mesh over the specified interval. To use the same interval for both u and v, specify uvinterval as a two-element vector of the form [min max]. To use different intervals, specify a four-element vector of the form [umin umax vmin vmax].

fmesh(___,LineSpec) sets the line style, marker symbol, and color of the mesh. For example, '-r' specifies red lines. Use this option after any of the previous input argument combinations.

example

fmesh(___,Name,Value) specifies properties of the mesh using one or more name-value pair arguments. Use this option with any of the input argument combinations in the previous syntaxes.

fmesh(ax,___) plots into the axes specified by ax instead of the current axes gca.

fs = fmesh(___) returns a FunctionSurface object or a ParameterizedFunctionSurface object, depending on the inputs. Use fs to query and modify properties of a specific surface. For a list of properties, see FunctionSurface Properties or ParameterizedFunctionSurface Properties.

Examples

collapse all

Plot a mesh of the input over the default interval and .

fmesh(@(x,y) sin(x)+cos(y))

Plot the parameterized mesh

for and . Make the mesh partially transparent using alpha.

r = @(s,t) 2 + sin(7.*s + 5.*t);
x = @(s,t) r(s,t).*cos(s).*sin(t);
y = @(s,t) r(s,t).*sin(s).*sin(t);
z = @(s,t) r(s,t).*cos(t);
fmesh(x,y,z,[0 2*pi 0 pi])

alpha(0.8)

Plot the piecewise input

over the interval

Specify the plotting interval as the second argument of fmesh. When you plot multiple inputs over different intervals in the same axes, the axis limits adjust to include all the data.

fmesh(@(x,y) erf(x)+cos(y),[-5 0 -5 5])
hold on
fmesh(@(x,y) sin(x)+cos(y),[0 5 -5 5])
hold off

Create a mesh plot using red lines.

fmesh(@(x,y) sin(x)+cos(y),'EdgeColor','red')

Input Arguments

collapse all

3-D function to plot, specified as a function handle to a named or anonymous function.

Specify a function of the form z = f(x,y). The function must accept two matrix input arguments and return a matrix output argument of the same size. Use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

Example: f = @(x,y) sin(x) + cos(y);

Plotting interval for x and y, specified in one of these forms:

  • Vector of form [min max] — Use the interval [min max] for both x and y

  • Vector of form [xmin xmax ymin ymax] — Use the interval [xmin xmax] for x and [ymin ymax] for y.

Parametric function for x coordinates, specified as a function handle to a named or anonymous function.

Specify a function of the form x = funx(u,v). The function must accept two matrix input arguments and return a matrix output argument of the same size. Use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

Example: funx = @(u,v) u.*sin(v);

Parametric function for y coordinates, specified as a function handle to a named or anonymous function.

Specify a function of the form y = funy(u,v). The function must accept two matrix input arguments and return a matrix output argument of the same size. Use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

Example: funy = @(t) @(u,v) -u.*cos(v);

Parametric function for z coordinates, specified as a function handle to a named or anonymous function.

Specify a function of the form z = funz(u,v). The function must accept two matrix input arguments and return a matrix output argument of the same size. Use array operators instead of matrix operators for the best performance. For example, use .* (times) instead of * (mtimes).

Example: funz = @(u,v) v;

Plotting interval for u and v, specified in one of these forms:

  • Vector of form [min max] — Use the interval [min max] for both u and v.

  • Vector of form [umin umax vmin vmax] — Use the interval [umin umax] for u and [vmin vmax] for v.

Axes object. If you do not specify an axes object, then fmesh uses the current axes.

Line specification, specified as a character vector or string with a line style, marker, and color. The elements can appear in any order, and you can omit one or more options. To show only markers with no connecting lines, specify a marker and omit the line style.

Example: 'r--o' specifies a red color, a dashed line, and circle markers

Line Style SpecifierDescription
-Solid line (default)
--Dashed line
:Dotted line
-.Dash-dot line
Marker SpecifierDescription
oCircle
+Plus sign
*Asterisk
.Point
xCross
sSquare
dDiamond
^Upward-pointing triangle
vDownward-pointing triangle
>Right-pointing triangle
<Left-pointing triangle
pPentagram
hHexagram
Color SpecifierDescription

y

yellow

m

magenta

c

cyan

r

red

g

green

b

blue

w

white

k

black

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'Marker','o','MarkerFaceColor','red'

The properties listed here are only a subset. For a full list, see FunctionSurface Properties.

collapse all

Number of evaluation points per direction, specified as a number. The default is 35. Because fmesh objects use adaptive evaluation, the actual number of evaluation points is greater.

Example: 100

Display contour plot under plot, specified as 'off' (default) or 'on'.

Line color, specified as 'interp', an RGB triplet, or one of the color options listed in the table. The default value of 'interp' colors the edges based on the ZData property values.

For a custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7]. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.

OptionDescriptionEquivalent RGB Triplet
'red' or 'r'Red[1 0 0]
'green' or 'g'Green[0 1 0]
'blue' or 'b'Blue[0 0 1]
'yellow' or 'y'Yellow[1 1 0]
'magenta' or 'm'Magenta[1 0 1]
'cyan' or 'c'Cyan[0 1 1]
'white' or 'w'White[1 1 1]
'black' or 'k'Black[0 0 0]
'none'No colorNot applicable

Example: 'blue'

Example: [0 0 1]

Line style, specified as one of the line styles listed in this table.

Line StyleDescriptionResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

Line width, specified as a positive value in points. If the line has markers, then the line width also affects the marker edges.

Example: 0.75

Marker symbol, specified as one of the values in this table. By default, a line does not have markers. Add markers at selected points along the line by specifying a marker.

ValueDescription
'o'Circle
'+'Plus sign
'*'Asterisk
'.'Point
'x'Cross
'square' or 's'Square
'diamond' or 'd'Diamond
'^'Upward-pointing triangle
'v'Downward-pointing triangle
'>'Right-pointing triangle
'<'Left-pointing triangle
'pentagram' or 'p'Five-pointed star (pentagram)
'hexagram' or 'h'Six-pointed star (hexagram)
'none'No markers

Marker outline color, specified as 'auto', an RGB triplet, or one of the color options listed in the table. The default value of 'auto' uses the same color as the EdgeColor property.

For a custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7]. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.

OptionDescriptionEquivalent RGB Triplet
'red' or 'r'Red[1 0 0]
'green' or 'g'Green[0 1 0]
'blue' or 'b'Blue[0 0 1]
'yellow' or 'y'Yellow[1 1 0]
'magenta' or 'm'Magenta[1 0 1]
'cyan' or 'c'Cyan[0 1 1]
'white' or 'w'White[1 1 1]
'black' or 'k'Black[0 0 0]
'none'No colorNot applicable

Example: [0.5 0.5 0.5]

Example: 'blue'

Marker fill color, specified as 'auto', an RGB triplet, or one of the color options listed in the table. The 'auto' value uses the same color as the MarkerEdgeColor property.

For a custom color, specify an RGB triplet. An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7]. Alternatively, you can specify some common colors by name. This table lists the long and short color name options and the equivalent RGB triplet values.

OptionDescriptionEquivalent RGB Triplet
'red' or 'r'Red[1 0 0]
'green' or 'g'Green[0 1 0]
'blue' or 'b'Blue[0 0 1]
'yellow' or 'y'Yellow[1 1 0]
'magenta' or 'm'Magenta[1 0 1]
'cyan' or 'c'Cyan[0 1 1]
'white' or 'w'White[1 1 1]
'black' or 'k'Black[0 0 0]
'none'No colorNot applicable

Example: [0.3 0.2 0.1]

Example: 'green'

Marker size, specified as a positive value in points.

Example: 10

Output Arguments

collapse all

One or more FunctionSurface or ParameterizedFunctionSurface objects, returned as a scalar or a vector.

  • If you use the fmesh(f) syntax or a variation of this syntax, then fmesh returns FunctionSurface objects.

  • If you use the fmesh(funx,funy,funz) syntax or a variation of this syntax, then fmesh returns ParameterizedFunctionSurface objects.

You can use these objects to query and modify properties of a specific mesh. For a list of properties, see FunctionSurface Properties and ParameterizedFunctionSurface Properties.

Introduced in R2016a

Was this topic helpful?