Main Content


N-D convex hull



k = convhulln(P) computes the N-D convex hull of the points in a matrix P.

k = convhulln(P,opts) also specifies the Qhull options used to compute the convex hull.


[k,vol] = convhulln(___) also returns the volume vol of the convex hull for either of the previous syntaxes.


collapse all

Create a matrix of 3-D points and compute the convex hull and its volume.

P = rand(10,3);
[k,vol] = convhulln(P);

Plot the convex hull.


Figure contains an axes. The axes contains an object of type patch.

Display the volume of the convex hull.

vol = 0.1857

Input Arguments

collapse all

Points, specified as a matrix whose columns contain the coordinates for the corresponding dimension. For example, to define a set of 2-D points, place the x-coordinates in the first column of P and the corresponding y-coordinates in the second column.

Qhull options, specified as a cell array of character vectors indicating which Qhull algorithms to use. For a list of options, see

By default, opts is set to {'Qt'} for 2-, 3-, and 4-dimensional input. For 5-dimensional input and higher, opts is set to {'Qt','Qx'}.

Output Arguments

collapse all

Indices, returned as a vector or matrix.

  • For 2-D points, k is a column vector containing the row indices of the input points that make up the convex hull, arranged counterclockwise.

  • For 3-D points, k is a three-column matrix where each row represents a facet of a triangulation that makes up the convex hull. The values represent the row indices of the input points.

  • For N-D points, k is an N-column matrix. The values represent the row indices of the input points.

Volume of the convex hull (area for two dimensions), returned as a scalar.



convhulln is based on Qhull [1]. For information, see For copyright information, see


[1] Barber, C.B., D.P. Dobkin, and H.T. Huhdanpaa. “The Quickhull Algorithm for Convex Hulls.” ACM Transactions on Mathematical Software, Vol. 22, No. 4, Dec. 1996, p 469–483.

Extended Capabilities

Introduced before R2006a