changeset 29284:067b663529bb stable

interpn.m: Fix check for scattered point coordinates (bug #59856). * scripts/general/interpn.m: Fix check for scattered point coordinates. Improve documentation for Y* input arguments.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 12 Jan 2021 15:46:53 +0100
parents 59696b24ea53
children 4b0c5070a332 4cb0fc7ecd4b
files scripts/general/interpn.m
diffstat 1 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/general/interpn.m	Mon Jan 04 16:09:33 2021 -0500
+++ b/scripts/general/interpn.m	Tue Jan 12 15:46:53 2021 +0100
@@ -37,9 +37,14 @@
 ## at a location given by the parameters @var{x1}, @var{x2}, @dots{}, @var{xn}.
 ## The parameters @var{x1}, @var{x2}, @dots{}, @var{xn} are either
 ## @var{n}-dimensional arrays of the same size as the array @var{v} in
-## the @qcode{"ndgrid"} format or vectors.  The parameters @var{y1}, etc.@:
-## respect a similar format to @var{x1}, etc., and they represent the points
-## at which the array @var{vi} is interpolated.
+## the @qcode{"ndgrid"} format or vectors.
+##
+## The parameters @var{y1}, @var{y2}, @dots{}, @var{yn} represent the points at
+## which the array @var{vi} is interpolated.  They can be vectors of the same
+## length and orientation in which case they are interpreted as coordinates of
+## scattered points.  If they are vectors of differing orientation or length,
+## they are used to form a grid in @qcode{"ndgrid"} format.  They can also be
+## @var{n}-dimensional arrays of equal size.
 ##
 ## If @var{x1}, @dots{}, @var{xn} are omitted, they are assumed to be
 ## @code{x1 = 1 : size (@var{v}, 1)}, etc.  If @var{m} is specified, then
@@ -168,8 +173,9 @@
   method = tolower (method);
 
   all_vectors = all (cellfun ("isvector", y));
-  different_lengths = numel (unique (cellfun ("numel", y))) > 1;
-  if (all_vectors && different_lengths)
+  sz_y = cellfun (@size, y, "uniformoutput", false);
+  same_size = isequal (sz_y{:});
+  if (all_vectors && ! same_size)
     [foobar(1:numel(y)).y] = ndgrid (y{:});
     y = {foobar.y};
   endif