This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


N-D convex hull


K = convhulln(X)
K = convhulln(X,options)
[K,v] = convhulln(...)


K = convhulln(X) returns the indices K of the points in X that make up the facets of the convex hull of X. If X contains 2-D coordinates or 3-D coordinates, then the facets form triangles or tetrahedra, respectively. In general, X can be an m-by-n array representing m points in n-dimensional space. If the convex hull has p facets then K has size p-by-n.

convhulln uses Qhull.

K = convhulln(X,options) specifies a cell array of Qhull options. The default options are:

  • {'Qt'} for 2-, 3-. and 4-dimensional input

  • {'Qt','Qx'} for 5-dimensional input and higher.

If options is [], the default options are used. For more information on Qhull and its options, see

[K,v] = convhulln(...) also returns the volume v of the convex hull.


Plotting the output of convhulln depends on the value of n:

  • For n = 2, use plot as you would for convhull.

  • For n = 3, you can use trisurf to plot the output. The calling sequence is

    K = convhulln(X);
  • You cannot plot convhulln output for n > 3.


The following example illustrates the options input for convhulln. The following commands

X = [0 0; 0 1e-10; 0 0; 1 1];
K = convhulln(X)

return a warning.

Warning: qhull precision warning: 
The initial hull is narrow 
(cosine of min. angle is 0.9999999999999998).
A coplanar point may lead to a wide facet. 
Options 'QbB' (scale to unit box) or 'Qbb' 
(scale last coordinate) may remove this warning. 
Use 'Pp' to skip this warning.

To suppress the warning, use the option 'Pp'. The following command passes the option 'Pp', along with the default 'Qt', to convhulln.

K = convhulln(X,{'Qt','Pp'})

K =

     1     4
     1     2
     4     2


convhulln is based on Qhull [1]. For information about Qhull, 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.

Introduced before R2006a

Was this topic helpful?