Mercurial > octave
comparison scripts/geometry/griddatan.m @ 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 | bb50407f9c60 |
children | 90fea9cc9caa |
comparison
equal
deleted
inserted
replaced
28215:ad71b30058ff | 28216:f5644ccd1df5 |
---|---|
72 ## legend ("Original Data", "Interpolated Data"); | 72 ## legend ("Original Data", "Interpolated Data"); |
73 ## @end group | 73 ## @end group |
74 ## @end example | 74 ## @end example |
75 ## | 75 ## |
76 ## Programming Notes: If the input is complex the real and imaginary parts | 76 ## Programming Notes: If the input is complex the real and imaginary parts |
77 ## are interpolated separately. For 2-D and 3-D data additional interpolation | 77 ## are interpolated separately. Interpolation is based on a Delaunay |
78 ## methods are available by using the @code{griddata} function. | 78 ## triangulation and any query values outside the convex hull of the input |
79 ## points will return @code{NaN}. For 2-D and 3-D data additional | |
80 ## interpolation methods are available by using the @code{griddata} function. | |
79 ## @seealso{griddata, griddata3, delaunayn} | 81 ## @seealso{griddata, griddata3, delaunayn} |
80 ## @end deftypefn | 82 ## @end deftypefn |
81 | 83 |
82 function yi = griddatan (x, y, xi, method = "linear", varargin) | 84 function yi = griddatan (x, y, xi, method = "linear", varargin) |
83 | 85 |
101 if (nargin > 3) | 103 if (nargin > 3) |
102 if (isempty (method)) | 104 if (isempty (method)) |
103 method = "linear"; | 105 method = "linear"; |
104 elseif (! ischar (method)) | 106 elseif (! ischar (method)) |
105 error ("griddatan: METHOD must be a string"); | 107 error ("griddatan: METHOD must be a string"); |
108 else | |
109 method = tolower (method); | |
106 endif | 110 endif |
107 | 111 |
108 method = tolower (method); | |
109 if (strcmp (method, "linear") || strcmp (method, "nearest")) | 112 if (strcmp (method, "linear") || strcmp (method, "nearest")) |
110 ## Do nothing, these are implemented methods | 113 ## Do nothing, these are implemented methods |
111 elseif (strcmp (method, "v4")) | 114 elseif (strcmp (method, "v4")) |
112 error ('griddatan: "%s" METHOD is available for 2-D inputs by using "griddata"', method); | 115 error ('griddatan: "%s" METHOD is available for 2-D inputs by using "griddata"', method); |
113 | 116 |