changeset 10780:6e7590d003dc

Fix bugs in interp2 (bug #29601)
author Thorsten Meyer <thorsten.meyier@gmx.de>
date Fri, 09 Jul 2010 19:56:21 +0200
parents add87b12e63c
children f7584d0ba5d3
files scripts/ChangeLog scripts/general/interp2.m
diffstat 2 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Fri Jul 09 14:12:59 2010 +0200
+++ b/scripts/ChangeLog	Fri Jul 09 19:56:21 2010 +0200
@@ -1,3 +1,8 @@
+2010-07-09  Thorsten Meyer  <thorsten.meyier@gmx.de>
+
+	* general/interp2.m: improve input argument handling and
+	allow not equally spaced griddata (bug #29601)
+
 2010-07-08  Jaroslav Hajek  <highegg@gmail.com>
 
 	* general/accumarray.m: Fix incorrect handling of nondefault fill
--- a/scripts/general/interp2.m	Fri Jul 09 14:12:59 2010 +0200
+++ b/scripts/general/interp2.m	Fri Jul 09 19:56:21 2010 +0200
@@ -318,7 +318,7 @@
 
   else
 
-    ## If X and Y vectors produce a grid from them
+    ## Check dimensions of X and Y
     if (isvector (X) && isvector (Y))
       X = X(:).';
       Y = Y(:);
@@ -332,10 +332,10 @@
       endif
     endif
 
-    ## If Xi and Yi are vectors of different orientation build a grid
-    if ((rows (XI) == 1 && columns (YI) == 1)
-        || (columns (XI) == 1 && rows (YI) == 1))
-      ## Do nothing
+    ## Check dimensions of XI and YI
+    if (isvector (XI) && isvector (YI))
+      XI = XI(:).';
+      YI = YI(:);
     elseif (! size_equal (XI, YI))
       error ("interp2: XI and YI must be matrices of same size");
     endif
@@ -409,8 +409,7 @@
 
 function b = isgriddata (X)
   d1 = diff (X, 1, 1);
-  d2 = diff (X, 1, 2);
-  b = all (d1 (:) == 0) & all (d2 (:) == d2 (1));
+  b = all (d1 (:) == 0);
 endfunction
 
 ## Compute the bicubic interpolation coefficients