FUNCTION REFERENCE

contourc

Contour matrix of a grid, without drawing.

Contour matrix of a grid, without drawing.

Syntax

C = contourc(Z)

Syntax

C = contourc(Z, n)

Syntax

C = contourc(Z, v)

Syntax

C = contourc(x, y, Z)

Syntax

C = contourc(x, y, Z, n)

Syntax

C = contourc(x, y, Z, v)

Traces the lines where Z crosses each level, by linear interpolation along the cell edges (marching squares). x and y are vectors with one entry per column and per row of Z (default 1:columns and 1:rows), or matrices of Z's size (meshgrid output, or a general mesh: the lines are traced in index space and mapped onto it bilinearly). Level rule: a count n gives n levels evenly spaced strictly inside the data range, linspace(min(Z(:)), max(Z(:)), n+2) without its two ends, NaN ignored; the default is n = 10. A vector v gives its sorted distinct values as the levels, so [k k] is the single level k. Layout of C: one block per line, a column [level; npoints] followed by the npoints [x; y] columns. Per level, lines that start on the top and bottom edges come first, then those on the left and right edges, then closed lines (which repeat their first point at the end). Cells with a NaN corner have no crossings on the edges that touch it. Constant Z or levels outside the data range give an empty 2-by-0 C.

Example

C = contourc([1 2; 3 4], [2.5 2.5])   % [2.5 1 2; 2 1.75 1.25] (one line, two points)

Example

size(contourc(peaks(20)))

Differences from MATLAB: the level rule and line order are GNU Octave's (the reference for the tests). Z must be real and finite or NaN, with at most 1000000 elements; at most 2000000 contour points; n is at most 1000.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.