[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[CHANGESET] Re: Help with griddata3
From: |
David Bateman |
Subject: |
[CHANGESET] Re: Help with griddata3 |
Date: |
Wed, 12 Mar 2008 15:07:07 +0100 |
User-agent: |
Thunderbird 2.0.0.12 (X11/20080306) |
António Santos wrote:
> Hi,
>
> I have a Fedora Core 6 system with Octave 2.9.9-1 and Octave-forge
> 2006.07.09-7 installed.
> I need to use the griddata3 function, which seems to not be present in
> these packages. I tried to download de griddata3.m from other
> distributions but I'm having no success with using this function.
> griddata3 calls griddata like the following:
> vi = griddata([x(:),y(:),z(:)],v(:),[xi(:),yi(:),zi(:)],varargin{:});
> However, griddata does not accept all these parameters...
> I also downloaded the source code from Octave 3.0.0 and, althought I
> didn't test it, it seems that the problem still persists.
> Any clue on how to use griddata3?
>
> Thanks,
>
> António Santos
>
>
Opps, that can't ever have worked as written, but I sure to have tested
this... In any case the fact that it doesn't work is my fault, and the
attached patch should fix it and adds test code.
D.
--
David Bateman address@hidden
Motorola Labs - Paris +33 1 69 35 48 04 (Ph)
Parc Les Algorithmes, Commune de St Aubin +33 6 72 01 06 33 (Mob)
91193 Gif-Sur-Yvette FRANCE +33 1 69 35 77 01 (Fax)
The information contained in this communication has been classified as:
[x] General Business Information
[ ] Motorola Internal Use Only
[ ] Motorola Confidential Proprietary
# HG changeset patch
# User David Bateman <address@hidden>
# Date 1205330700 -3600
# Node ID 33c8aade7c453c1ae32f46d69298840024e72af6
# Parent f761dc86ed70deaa223a6c0052c5d8e5a381c6ea
Fix griddata3 and add test code
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,8 @@ 2008-03-11 John W. Eaton <address@hidden
+2008-03-12 David Bateman <address@hidden>
+
+ * geometry/griddata3.m: Use griddatan and not griddata
+ internally. Return vi and not yi. Add test code.
+
2008-03-11 John W. Eaton <address@hidden>
* plot/__go_draw_axes__.m: Use get to access hidden properties.
diff --git a/scripts/geometry/griddata3.m b/scripts/geometry/griddata3.m
--- a/scripts/geometry/griddata3.m
+++ b/scripts/geometry/griddata3.m
@@ -30,7 +30,7 @@
## Author: David Bateman <address@hidden>
-function [yi] = griddata3 (x, y, z,v, xi, yi, zi, method, varargin)
+function vi = griddata3 (x, y, z, v, xi, yi, zi, method, varargin)
if (nargin < 7)
print_usage ();
@@ -48,10 +48,33 @@ function [yi] = griddata3 (x, y, z,v, xi
endif
if (any (size(xi) != size(yi)) || any (size(xi) != size(zi)))
- error ("griddata: xi, yi and zi must be vectors or matrices of same size");
+ error ("griddata3: xi, yi and zi must be vectors or matrices of same
size");
endif
- vi = griddata ([x(:), y(:), z(:)], v(:), [xi(:), yi(:), zi(:)], varargin{:});
+ vi = griddatan ([x(:), y(:), z(:)], v(:), [xi(:), yi(:), zi(:)],
varargin{:});
vi = reshape (vi, size (xi));
endfunction
+%!test
+%! rand('state', 0);
+%! x = 2 * rand(1000, 1) - 1;
+%! y = 2 * rand(1000, 1) - 1;
+%! z = 2 * rand(1000, 1) - 1;
+%! v = x.^2 + y.^2 + z.^2;
+%! [xi, yi, zi] = meshgrid (-0.8:0.2:0.8);
+%! ##vi = reshape (griddatan([x(:), y(:), z(:)], v, [xi(:), yi(:), zi(:)],
'linear'), size (xi));
+%! vi = griddata3 (x, y, z, v, xi, yi, zi, 'linear');
+%! vv = vi - xi.^2 - yi.^2 - zi.^2;
+%! assert (max(abs(vv(:))), 0, 0.1)
+
+%!test
+%! rand('state', 0);
+%! x = 2 * rand(1000, 1) - 1;
+%! y = 2 * rand(1000, 1) - 1;
+%! z = 2 * rand(1000, 1) - 1;
+%! v = x.^2 + y.^2 + z.^2;
+%! [xi, yi, zi] = meshgrid (-0.8:0.2:0.8);
+%! ##vi = reshape (griddatan([x(:), y(:), z(:)], v, [xi(:), yi(:), zi(:)],
'linear'), size (xi));
+%! vi = griddata3 (x, y, z, v, xi, yi, zi, 'nearest');
+%! vv = vi - xi.^2 - yi.^2 - zi.^2;
+%! assert (max(abs(vv(:))), 0, 0.1)