# HG changeset patch # User Rik # Date 1329430725 28800 # Node ID 079e6f3a09776551bfcdebfe1771707a3a033f99 # Parent fbdee844550c239f4e38f0e67d85d56dbb6b5272 griddata3.m: Accept vectors of any orientation. Update docstring. * griddata3.m: Accept vectors of any orientation. Update docstring. diff -r fbdee844550c -r 079e6f3a0977 scripts/geometry/griddata3.m --- a/scripts/geometry/griddata3.m Thu Feb 16 14:17:26 2012 -0800 +++ b/scripts/geometry/griddata3.m Thu Feb 16 14:18:45 2012 -0800 @@ -17,7 +17,9 @@ ## . ## -*- texinfo -*- -## @deftypefn {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options}) +## @deftypefn {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}) +## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}) +## @deftypefnx {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options}) ## ## Generate a regular mesh from irregular data using interpolation. ## The function is defined by @code{@var{y} = f (@var{x},@var{y},@var{z})}. @@ -25,7 +27,12 @@ ## ## The interpolation method can be @code{"nearest"} or @code{"linear"}. ## If method is omitted it defaults to @code{"linear"}. -## @seealso{griddata, delaunayn} +## +## The optional argument @var{options} is passed directly to Qhull when +## computing the Delaunay triangulation used for interpolation. See +## @code{delaunayn} for information on the defaults and how to pass different +## values. +## @seealso{griddata, griddatan, delaunayn} ## @end deftypefn ## Author: David Bateman @@ -36,19 +43,29 @@ print_usage (); endif - if (!all (size (x) == size (y) & size (x) == size(z) & size(x) == size (v))) - error ("griddata3: X, Y, Z, and V must be vectors of same length"); + if (isvector (x) && isvector (y) && isvector (z) && isvector (v)) + if (! isequal (length (x), length (y), length (z), length (v))) + error ("griddata: X, Y, Z, and V must be vectors of the same length"); + endif + elseif (! size_equal (x, y, z, v)) + error ("griddata: X, Y, Z, and V must have equal sizes"); endif - ## meshgrid xi, yi and zi if they are vectors unless they - ## are vectors of the same length - if (isvector (xi) && isvector (yi) && isvector (zi) - && (numel (xi) != numel (yi) || numel (xi) != numel (zi))) - [xi, yi, zi] = meshgrid (xi, yi, zi); + ## meshgrid xi, yi and zi if they are vectors unless + ## they are vectors of the same length. + if (isvector (xi) && isvector (yi) && isvector (zi)) + if (! isequal (length (xi), length (yi), length (zi))) + [xi, yi, zi] = meshgrid (xi, yi, zi); + else + ## Otherwise, convert to column vectors + xi = xi(:); + yi = yi(:); + zi = zi(:); + endif endif - if (any (size(xi) != size(yi)) || any (size(xi) != size(zi))) - error ("griddata3: XI, YI and ZI must be vectors or matrices of same size"); + if (! size_equal (xi, yi, zi)) + error ("griddata3: XI, YI, and ZI must be vectors or matrices of the same size"); endif vi = griddatan ([x(:), y(:), z(:)], v(:), [xi(:), yi(:), zi(:)], varargin{:});