changeset 20214:561af1ab6099

griddata.m: Return values instead of plotting for Matlab compatibility (bug #45125) * griddata.m: Return interpolated values instead of plotting a mesh for compatibility with Matlab. Adjust %!demos to call mesh on the output. * NEWS: Mention change to griddata for 4.2.
author Mike Miller <mtmiller@octave.org>
date Thu, 21 May 2015 22:35:51 -0400
parents f2bc7d23295d
children 4e15a4c331e7
files NEWS scripts/geometry/griddata.m
diffstat 2 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu May 21 10:22:27 2015 -0700
+++ b/NEWS	Thu May 21 22:35:51 2015 -0400
@@ -15,6 +15,10 @@
  ** mkfifo now interprets the MODE argument as an octal, not decimal, integer.
     This is consistent with the equivalent shell command. 
 
+ ** The griddata function no longer plots the interpolated mesh if no output
+    argument is requested, instead the vector or array of interpolated values
+    is always returned for Matlab compatibility.
+
  ** Other new functions added in 4.2:
 
       psi
--- a/scripts/geometry/griddata.m	Thu May 21 10:22:27 2015 -0700
+++ b/scripts/geometry/griddata.m	Thu May 21 22:35:51 2015 -0400
@@ -133,14 +133,12 @@
     error ("griddata: unknown interpolation METHOD");
   endif
 
-  if (nargout == 3)
+  if (nargout > 1)
     rx = xi;
     ry = yi;
     rz = zi;
-  elseif (nargout == 1)
+  else
     rx = zi;
-  elseif (nargout == 0)
-    mesh (xi, yi, zi);
   endif
 
 endfunction
@@ -153,7 +151,8 @@
 %! y = 2*rand (size (x)) - 1;
 %! z = sin (2*(x.^2 + y.^2));
 %! [xx,yy] = meshgrid (linspace (-1,1,32));
-%! griddata (x,y,z,xx,yy);
+%! zz = griddata (x,y,z,xx,yy);
+%! mesh (xx, yy, zz);
 %! title ("nonuniform grid sampled at 100 points");
 
 %!demo
@@ -163,7 +162,8 @@
 %! y = 2*rand (size (x)) - 1;
 %! z = sin (2*(x.^2 + y.^2));
 %! [xx,yy] = meshgrid (linspace (-1,1,32));
-%! griddata (x,y,z,xx,yy);
+%! zz = griddata (x,y,z,xx,yy);
+%! mesh (xx, yy, zz);
 %! title ("nonuniform grid sampled at 1000 points");
 
 %!demo
@@ -173,7 +173,8 @@
 %! y = 2*rand (size (x)) - 1;
 %! z = sin (2*(x.^2 + y.^2));
 %! [xx,yy] = meshgrid (linspace (-1,1,32));
-%! griddata (x,y,z,xx,yy,"nearest");
+%! zz = griddata (x,y,z,xx,yy,"nearest");
+%! mesh (xx, yy, zz);
 %! title ("nonuniform grid sampled at 1000 points with nearest neighbor");
 
 %!testif HAVE_QHULL