6823
|
1 ## Copyright (C) 2007 David Bateman <dbateman@free.fr> |
|
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 |
6826
|
31 function [yi] = griddata3 (x, y, z,v, xi, yi, zi, method, varargin) |
6823
|
32 |
6826
|
33 if (nargin < 7) |
|
34 print_usage (); |
6823
|
35 endif |
|
36 |
6826
|
37 if (!all (size (x) == size (y) & size (x) == size(z) & size(x) == size (v))) |
|
38 error ("griddata3: x, y, z, and v must be vectors of same length"); |
6823
|
39 endif |
|
40 |
|
41 ## meshgrid xi, yi and zi if they are vectors unless they |
|
42 ## are vectors of the same length |
6826
|
43 if (isvector (xi) && isvector (yi) && isvector (zi) |
|
44 && (numel (xi) != numel (yi) || numel (xi) != numel (zi))) |
|
45 [xi, yi, zi] = meshgrid (xi, yi, zi); |
6823
|
46 endif |
|
47 |
6826
|
48 if (any (size(xi) != size(yi)) || any (size(xi) != size(zi))) |
|
49 error ("griddata: xi, yi and zi must be vectors or matrices of same size"); |
6823
|
50 endif |
|
51 |
6826
|
52 vi = gridata ([x(:), y(:), z(:)], v(:), [xi(:), yi(:), zi(:)], varargin{:}); |
|
53 vi = reshape (vi, size (xi)); |
6823
|
54 endfunction |
|
55 |