# mesh, meshc, meshz

## Purpose

3-D mesh surface plot.

## Synopsis

````mesh(X,Y,Z,C)`
`mesh(X,Y,Z)`
`mesh(x,y,Z,C)`
`mesh(x,y,Z)`
`mesh(Z,C)`
`mesh(Z)`
`h = mesh(...)`
`h = meshc(...)`
h = meshz(...)
```

## Description

For a complete discussion of parametric surfaces, please refer to `surf`.

In its most general invocation, `mesh` has four matrix input arguments. `mesh(X,Y,Z,C)` plots the colored grid lines on the parametric surface specified by `X`, `Y`, and `Z`, with color specified by `C`. In simpler uses, `X` and `Y` can be vectors, or can be omitted, and `C` can be omitted.

The view point is specified by `view`. Axis labels are determined by the range of `X`, `Y`, and `Z`, or by the current setting of `axis`. The color scaling is determined by the range of `C`, or by the current setting of `caxis`. The scaled color values are used as indices into the current colormap.

`mesh(X,Y,Z)` uses `C = Z`, so color is proportional to surface height.

`mesh(x,y,Z,C)` and `mesh(x,y,Z)`, with two vector arguments replacing the first two matrix arguments, must have `length(x) = n` and `length(y) = m` where `[m`,`n] = size(Z)`. In this case, the intersections of the grid lines are the triples `(x(j),y(i),Z(i`,`j))`. Note that `x` corresponds to the columns of `Z` and `y` corresponds to the rows.

`mesh(Z,C)` and `mesh(Z)` use `x = 1:n` and `y = 1:m`.

`h = mesh(...)` returns a handle to a `surface` object. `surface` objects are children of `axes` objects.

`meshc(...)` is the same as `mesh(...)` except that a contour plot is drawn beneath the mesh.

`meshz(...)` is the same as `mesh(...)` except that a curtain plot, or reference plane, is drawn beneath the mesh.

## Examples

Produce a combination mesh and contour plot of the `peaks` surface.

````[x,y] = meshgrid(-3:.125:3);`
`z = peaks(x,y);`
`meshc(x,y,z);`
`          `

```
Generate the curtain plot for the `peaks` function.

````[x,y] = meshgrid(-3:.125:3);`
`z = peaks(x,y);`
`meshz(x,y,z)`
`          `

```

## Algorithm

`meshc` calls `mesh`, turns `hold` on, and then calls `contour` with an offset. If you need additional control over the appearance of the contours, you can issue these commands directly. You can also combine other types of graphs in this manner, for example `surf` and `pcolor` plots.

## Limitations

`meshc` assumes that vectors `x` and `y` are monotonically increasing. If `x` and `y` are irregularly spaced, the contours are simply stretched apart, which is not the same as contouring the irregularly spaced data.

````axis`, `caxis`, `colormap`, `contour`, `hold`, `image`, `meshc`, `pcolor`, `shading`,
`surf`, `surfc`, `surfl`, `view `
```

(c) Copyright 1994 by The MathWorks, Inc.