Mercurial > hg > octave-lojdl
changeset 14267:527ed2a51d54
convhull.m: Allow non-vector arguments, for Matlab compatibility
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Fri, 27 Jan 2012 13:23:30 -0500 |
parents | 37ca58f9a887 |
children | e2a14d1b4eaa |
files | scripts/geometry/convhull.m |
diffstat | 1 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/geometry/convhull.m +++ b/scripts/geometry/convhull.m @@ -20,7 +20,7 @@ ## @deftypefn {Function File} {@var{H} =} convhull (@var{x}, @var{y}) ## @deftypefnx {Function File} {@var{H} =} convhull (@var{x}, @var{y}, @var{options}) ## Compute the convex hull of the set of points defined by the -## vectors @var{x} and @var{y}. The hull @var{H} is an index vector into +## arrays @var{x} and @var{y}. The hull @var{H} is an index vector into ## the set of points and specifies which points form the enclosing hull. ## ## An optional third argument, which must be a string or cell array of strings, @@ -45,17 +45,24 @@ print_usage (); endif - if (! (isvector (x) && isvector (y) && length (x) == length (y)) - && ! size_equal (x, y)) - error ("convhull: X and Y must be the same size"); + if (! isvector(x)) + x = x(:); + endif + + if (! isvector(y)) + y = y(:); + endif + + if (length (x) != length (y)) + error ("convhull: X and Y must have the same size"); elseif (nargin == 3 && ! (ischar (options) || iscellstr (options))) error ("convhull: OPTIONS must be a string or cell array of strings"); endif if (nargin == 2) - i = convhulln ([x(:), y(:)]); + i = convhulln ([x, y]); else - i = convhulln ([x(:), y(:)], options); + i = convhulln ([x, y], options); endif n = rows (i);