Navigation

Operators and Keywords

Function List:

C++ API

: [c, lev] = contourc (z)
: [c, lev] = contourc (z, vn)
: [c, lev] = contourc (x, y, z)
: [c, lev] = contourc (x, y, z, vn)

Compute contour lines (isolines of constant Z value).

The matrix z contains height values above the rectangular grid determined by x and y. If only a single input z is provided then x is taken to be 1:rows (z) and y is taken to be 1:columns (z).

The optional input vn is either a scalar denoting the number of contour lines to compute or a vector containing the Z values where lines will be computed. When vn is a vector the number of contour lines is numel (vn). However, to compute a single contour line at a given value use vn = [val, val]. If vn is omitted it defaults to 10.

The return value c is a 2xn matrix containing the contour lines in the following format

c = [lev1, x1, x2, …, levn, x1, x2, ...
     len1, y1, y2, …, lenn, y1, y2, …]

in which contour line n has a level (height) of levn and length of lenn.

The optional return value lev is a vector with the Z values of the contour levels.

Example:

x = 0:2;
y = x;
z = x' * y;
contourc (x, y, z, 2:3)
   ⇒   2.0000   2.0000   1.0000   3.0000   1.5000   2.0000
        2.0000   1.0000   2.0000   2.0000   2.0000   1.5000

See also: contour, contourf, contour3, clabel.

Package: octave