changeset 28216:f5644ccd1df5

griddata.m, griddatan.m: Small tweak in input validation. * griddata.m: Only call tolower on METHOD input when it is required. * griddatan.m: Only call tolower on METHOD input when it is required. Add note to documentation that query values outside the convex hull will return NaN.
author Rik <rik@octave.org>
date Mon, 13 Apr 2020 18:19:41 -0700
parents ad71b30058ff
children 8619dc0d3749
files scripts/geometry/griddata.m scripts/geometry/griddatan.m
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/geometry/griddata.m	Mon Apr 13 18:10:45 2020 -0700
+++ b/scripts/geometry/griddata.m	Mon Apr 13 18:19:41 2020 -0700
@@ -129,8 +129,9 @@
         method = "linear";
       elseif (! ischar (method))
         error ("griddata: METHOD must be a string");
+      else
+        method = tolower (method);
       endif
-      method = tolower (method);
 
       if (any (strcmp (method, {"linear", "nearest", "v4"})))
         ## Do nothing, these are implemented methods
--- a/scripts/geometry/griddatan.m	Mon Apr 13 18:10:45 2020 -0700
+++ b/scripts/geometry/griddatan.m	Mon Apr 13 18:19:41 2020 -0700
@@ -74,8 +74,10 @@
 ## @end example
 ##
 ## Programming Notes: If the input is complex the real and imaginary parts
-## are interpolated separately.  For 2-D and 3-D data additional interpolation
-## methods are available by using the @code{griddata} function.
+## are interpolated separately.  Interpolation is based on a Delaunay
+## triangulation and any query values outside the convex hull of the input
+## points will return @code{NaN}.  For 2-D and 3-D data additional
+## interpolation methods are available by using the @code{griddata} function.
 ## @seealso{griddata, griddata3, delaunayn}
 ## @end deftypefn
 
@@ -103,9 +105,10 @@
       method = "linear";
     elseif (! ischar (method))
       error ("griddatan: METHOD must be a string");
+    else
+      method = tolower (method);
     endif
 
-    method = tolower (method);
     if (strcmp (method, "linear") || strcmp (method, "nearest"))
       ## Do nothing, these are implemented methods
     elseif (strcmp (method, "v4"))