7017
|
1 ## Copyright (C) 2007 David Bateman |
6823
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
7016
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
6823
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
7016
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
6823
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {@var{vi} =} griddata3 (@var{x}, @var{y}, @var{z}, @var{v} @var{xi}, @var{yi}, @var{zi}, @var{method}, @var{options}) |
|
21 ## |
|
22 ## Generate a regular mesh from irregular data using interpolation. |
|
23 ## The function is defined by @code{@var{y} = f (@var{x},@var{y},@var{z})}. |
|
24 ## The interpolation points are all @var{xi}. |
|
25 ## |
6826
|
26 ## The interpolation method can be @code{"nearest"} or @code{"linear"}. |
|
27 ## If method is omitted it defaults to @code{"linear"}. |
6823
|
28 ## @seealso{griddata, delaunayn} |
|
29 ## @end deftypefn |
|
30 |
7017
|
31 ## Author: David Bateman <dbateman@free.fr> |
|
32 |
6826
|
33 function [yi] = griddata3 (x, y, z,v, xi, yi, zi, method, varargin) |
6823
|
34 |
6826
|
35 if (nargin < 7) |
|
36 print_usage (); |
6823
|
37 endif |
|
38 |
6826
|
39 if (!all (size (x) == size (y) & size (x) == size(z) & size(x) == size (v))) |
|
40 error ("griddata3: x, y, z, and v must be vectors of same length"); |
6823
|
41 endif |
|
42 |
|
43 ## meshgrid xi, yi and zi if they are vectors unless they |
|
44 ## are vectors of the same length |
6826
|
45 if (isvector (xi) && isvector (yi) && isvector (zi) |
|
46 && (numel (xi) != numel (yi) || numel (xi) != numel (zi))) |
|
47 [xi, yi, zi] = meshgrid (xi, yi, zi); |
6823
|
48 endif |
|
49 |
6826
|
50 if (any (size(xi) != size(yi)) || any (size(xi) != size(zi))) |
|
51 error ("griddata: xi, yi and zi must be vectors or matrices of same size"); |
6823
|
52 endif |
|
53 |
7418
|
54 vi = griddata ([x(:), y(:), z(:)], v(:), [xi(:), yi(:), zi(:)], varargin{:}); |
6826
|
55 vi = reshape (vi, size (xi)); |
6823
|
56 endfunction |
|
57 |