contourc
Computes contour line coordinates without drawing them.
Category: Graphics > 2-D and 3-D Plots
Syntax
C = contourc(Z)
Contour matrix for automatically chosen levels of Z.
C = contourc(Z, levels)
Uses the given number of levels or level values.
C = contourc(x, y, Z, levels)
Uses the coordinate vectors x and y.
Description
contourc is the numerical core behind contour. Use it when you need the line coordinates as data, for example to measure a level curve or to plot it with plot. A closed curve repeats its first point at the end.
Input arguments
Z- Matrix of values, at least 2 by 2.
x, y- Coordinate vectors matching the columns and rows of
Z. levels- Number of levels, or a vector of level values. Repeat a value, as in
[v v], to get a single level.
Output arguments
C- Two-row matrix. Each line starts with a column holding the level (row 1) and the number of points (row 2), followed by that many columns of x (row 1) and y (row 2) coordinates.
Example
Coordinates of one level
[X, Y] = meshgrid(-2:2);
Z = X.^2 + Y.^2;
C = contourc(Z, [1 1])
Output
C = 2×6
1 3 2 3 4 3
5 2 3 4 3 2