Mercurial > octave
annotate scripts/general/interp3.m @ 29359:7854d5752dd2
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 10:10:40 -0500 |
parents | 3cac3ceb9629 0a5b15007766 |
children | 796f54d4ddbf |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 ######################################################################## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 ## |
29358
0a5b15007766
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27923
diff
changeset
|
3 ## Copyright (C) 2007-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27854
diff
changeset
|
4 ## |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 ## See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 ## distribution or <https://octave.org/copyright/>. |
6702 | 7 ## |
8 ## This file is part of Octave. | |
9 ## | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
10 ## Octave is free software: you can redistribute it and/or modify it |
6702 | 11 ## under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
12 ## the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
13 ## (at your option) any later version. |
6702 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
18 ## GNU General Public License for more details. |
6702 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 21 ## along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
22 ## <https://www.gnu.org/licenses/>. |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 ## |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 ######################################################################## |
6702 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
27 ## @deftypefn {} {@var{vi} =} interp3 (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
28 ## @deftypefnx {} {@var{vi} =} interp3 (@var{v}, @var{xi}, @var{yi}, @var{zi}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
29 ## @deftypefnx {} {@var{vi} =} interp3 (@var{v}, @var{n}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
30 ## @deftypefnx {} {@var{vi} =} interp3 (@var{v}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
31 ## @deftypefnx {} {@var{vi} =} interp3 (@dots{}, @var{method}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20735
diff
changeset
|
32 ## @deftypefnx {} {@var{vi} =} interp3 (@dots{}, @var{method}, @var{extrapval}) |
6702 | 33 ## |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
34 ## Three-dimensional interpolation. |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
35 ## |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
36 ## Interpolate reference data @var{x}, @var{y}, @var{z}, @var{v} to determine |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
37 ## @var{vi} at the coordinates @var{xi}, @var{yi}, @var{zi}. The reference |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
38 ## data @var{x}, @var{y}, @var{z} can be matrices, as returned by |
20158
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
39 ## @code{meshgrid}, in which case the sizes of @var{x}, @var{y}, @var{z}, and |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
40 ## @var{v} must be equal. If @var{x}, @var{y}, @var{z} are vectors describing |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
41 ## a cubic grid then @code{length (@var{x}) == columns (@var{v})}, |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
42 ## @code{length (@var{y}) == rows (@var{v})}, and |
7503499a252b
doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
43 ## @code{length (@var{z}) == size (@var{v}, 3)}. In either case the input |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
44 ## data must be strictly monotonic. |
6702 | 45 ## |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
46 ## If called without @var{x}, @var{y}, @var{z}, and just a single reference |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
47 ## data matrix @var{v}, the 3-D region |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
48 ## @code{@var{x} = 1:columns (@var{v}), @var{y} = 1:rows (@var{v}), |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
49 ## @var{z} = 1:size (@var{v}, 3)} is assumed. |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
50 ## This saves memory if the grid is regular and the distance between points is |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
51 ## not important. |
6702 | 52 ## |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
53 ## If called with a single reference data matrix @var{v} and a refinement |
21546
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
54 ## value @var{n}, then perform interpolation over a 3-D grid where each |
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
55 ## original interval has been recursively subdivided @var{n} times. This |
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
56 ## results in @code{2^@var{n}-1} additional points for every interval in the |
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
57 ## original grid. If @var{n} is omitted a value of 1 is used. As an |
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
58 ## example, the interval [0,1] with @code{@var{n}==2} results in a refined |
f7f97d7e9294
doc: Wrap m-file docstrings to 79 characters + newline (80 total).
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
59 ## interval with points at [0, 1/4, 1/2, 3/4, 1]. |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
60 ## |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
61 ## The interpolation @var{method} is one of: |
6702 | 62 ## |
63 ## @table @asis | |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15333
diff
changeset
|
64 ## @item @qcode{"nearest"} |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
65 ## Return the nearest neighbor. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
66 ## |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
67 ## @item @qcode{"linear"} (default) |
9070
e9dc2ed2ec0f
Cleanup documentation for poly.texi, interp.texi, geometry.texi
Rik <rdrider0-list@yahoo.com>
parents:
9051
diff
changeset
|
68 ## Linear interpolation from nearest neighbors. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
69 ## |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
70 ## @item @qcode{"cubic"} |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
71 ## Piecewise cubic Hermite interpolating polynomial---shape-preserving |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
72 ## interpolation with smooth first derivative (not implemented yet). |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
73 ## |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
15333
diff
changeset
|
74 ## @item @qcode{"spline"} |
12175
2090995ca588
Correct en-dash,em-dash instances in docstrings.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
75 ## Cubic spline interpolation---smooth first and second derivatives |
6702 | 76 ## throughout the curve. |
77 ## @end table | |
78 ## | |
19795
ca7599ae464d
doc: Grammarcheck documentation ahead of 4.0 release.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
79 ## @var{extrapval} is a scalar number. It replaces values beyond the endpoints |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
80 ## with @var{extrapval}. Note that if @var{extrapval} is used, @var{method} |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
81 ## must be specified as well. If @var{extrapval} is omitted and the |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
82 ## @var{method} is @qcode{"spline"}, then the extrapolated values of the |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
83 ## @qcode{"spline"} are used. Otherwise the default @var{extrapval} value for |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
84 ## any other @var{method} is @qcode{"NA"}. |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
85 ## @seealso{interp1, interp2, interpn, meshgrid} |
6702 | 86 ## @end deftypefn |
87 | |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
88 ## FIXME: Need to add support for 'cubic' method (maybe change interpn). |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
89 |
6702 | 90 function vi = interp3 (varargin) |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
91 |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
92 narginchk (1,9); |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
93 |
6702 | 94 method = "linear"; |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
95 extrapval = []; |
6702 | 96 nargs = nargin; |
97 | |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
98 if (! isnumeric (varargin{1})) |
6702 | 99 print_usage (); |
100 endif | |
101 | |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
102 if (nargs > 1 && ischar (varargin{end-1})) |
7174 | 103 if (! isnumeric (varargin{end}) || ! isscalar (varargin{end})) |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
104 error ("interp3: EXTRAPVAL must be a numeric scalar"); |
6702 | 105 endif |
7174 | 106 extrapval = varargin{end}; |
107 method = varargin{end-1}; | |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
108 nargs -= 2; |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
109 elseif (ischar (varargin{end})) |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
110 method = varargin{end}; |
20735
418ae0cb752f
Replace ++,-- with in-place operators for performance.
Rik <rik@octave.org>
parents:
20158
diff
changeset
|
111 nargs -= 1; |
6702 | 112 endif |
113 | |
18587
5cf9a02732b6
Issue warning when '*' flag used with interp2,3,n.m (bug #41459).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 if (method(1) == "*") |
5cf9a02732b6
Issue warning when '*' flag used with interp2,3,n.m (bug #41459).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
115 warning ("interp3: ignoring unsupported '*' flag to METHOD"); |
5cf9a02732b6
Issue warning when '*' flag used with interp2,3,n.m (bug #41459).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
116 method(1) = []; |
5cf9a02732b6
Issue warning when '*' flag used with interp2,3,n.m (bug #41459).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
117 endif |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
118 method = validatestring (method, {"nearest", "linear", "cubic", "spline"}); |
18587
5cf9a02732b6
Issue warning when '*' flag used with interp2,3,n.m (bug #41459).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
119 |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
120 if (nargs < 3) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
121 ## Calling form interp3 (v) OR interp3 (v, n) |
7174 | 122 v = varargin{1}; |
6702 | 123 if (ndims (v) != 3) |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
124 error ("interp3: V must be a 3-D array of values"); |
6702 | 125 endif |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
126 n = varargin(2:nargs); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
127 v = permute (v, [2, 1, 3]); |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
128 if (isempty (extrapval)) |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
129 vi = interpn (v, n{:}, method); |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
130 else |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
131 vi = interpn (v, n{:}, method, extrapval); |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
132 endif |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
133 |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
134 elseif (nargs == 4 && ! isvector (varargin{1})) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
135 ## Calling form interp3 (v, xi, yi, zi) |
7174 | 136 v = varargin{1}; |
6702 | 137 if (ndims (v) != 3) |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
138 error ("interp3: V must be a 3-D array of values"); |
6702 | 139 endif |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
140 xi = varargin(2:4); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
141 if (any (! cellfun (@isvector, xi))) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
142 ## Meshgridded values rather than vectors |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
143 if (! size_equal (xi{:})) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
144 error ("interp3: XI, YI, and ZI dimensions must be equal"); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
145 endif |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
146 for i = 1 : 3 |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
147 xi{i} = permute (xi{i}, [2, 1, 3]); |
6722 | 148 endfor |
149 endif | |
150 v = permute (v, [2, 1, 3]); | |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
151 if (isempty (extrapval)) |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
152 vi = interpn (v, xi{:}, method); |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
153 else |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
154 vi = interpn (v, xi{:}, method, extrapval); |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
155 endif |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
156 |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
157 elseif (nargs == 7) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
158 ## Calling form interp3 (x, y, z, v, xi, yi, zi) |
7174 | 159 v = varargin{4}; |
6702 | 160 if (ndims (v) != 3) |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
161 error ("interp3: V must be a 3-D array of values"); |
6702 | 162 endif |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
163 x = varargin(1:3); |
6722 | 164 if (any (! cellfun (@isvector, x))) |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
165 ## Meshgridded values rather than vectors |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
166 if (! size_equal (x{:}, v)) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
167 error ("interp3: X, Y, Z, and V dimensions must be equal"); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
168 endif |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
169 for i = 1 : 3 |
10549 | 170 x{i} = permute (x{i}, [2, 1, 3]); |
6722 | 171 endfor |
172 endif | |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
173 xi = varargin(5:7); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
174 if (any (! cellfun (@isvector, xi))) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
175 ## Meshgridded values rather than vectors |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
176 if (! size_equal (xi{:})) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
177 error ("interp3: XI, YI, and ZI dimensions must be equal"); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
178 endif |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
179 for i = 1 : 3 |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
180 xi{i} = permute (xi{i}, [2, 1, 3]); |
6722 | 181 endfor |
182 endif | |
183 v = permute (v, [2, 1, 3]); | |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
184 if (isempty (extrapval)) |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
185 vi = interpn (x{:}, v, xi{:}, method); |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
186 else |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
187 vi = interpn (x{:}, v, xi{:}, method, extrapval); |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
188 endif |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
189 |
6702 | 190 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
191 error ("interp3: wrong number or incorrectly formatted input arguments"); |
6702 | 192 endif |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
193 |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
194 if (! isvector (vi)) |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
195 vi = ipermute (vi, [2, 1, 3]); |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
196 endif |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
197 |
6702 | 198 endfunction |
199 | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14359
diff
changeset
|
200 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19795
diff
changeset
|
201 ## FIXME: Need some demo blocks here to show off the function like interp2.m. |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
202 |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
203 %!test # basic test |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
204 %! x = y = z = -1:1; y = y + 2; |
6702 | 205 %! f = @(x,y,z) x.^2 - y - z.^2; |
206 %! [xx, yy, zz] = meshgrid (x, y, z); | |
207 %! v = f (xx,yy,zz); | |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
208 %! xi = yi = zi = -1:0.5:1; yi = yi + 2.1; |
6702 | 209 %! [xxi, yyi, zzi] = meshgrid (xi, yi, zi); |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14359
diff
changeset
|
210 %! vi = interp3 (x, y, z, v, xxi, yyi, zzi); |
15333
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
211 %! [xxi, yyi, zzi] = ndgrid (yi, xi, zi); |
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
212 %! vi2 = interpn (y, x, z, v, xxi, yyi, zzi); |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
213 %! assert (vi, vi2, 10*eps); |
15333
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
214 |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
215 %!test # meshgridded xi, yi, zi |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
216 %! x = z = 1:2; y = 1:3; |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
217 %! v = ones ([3,2,2]); v(:,2,1) = [7;5;4]; v(:,1,2) = [2;3;5]; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
218 %! xi = zi = .6:1.6; yi = 1; |
15333
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
219 %! [xxi3, yyi3, zzi3] = meshgrid (xi, yi, zi); |
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
220 %! [xxi, yyi, zzi] = ndgrid (yi, xi, zi); |
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
221 %! vi = interp3 (x, y, z, v, xxi3, yyi3, zzi3, "nearest"); |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
222 %! vi2 = interpn (y, x, z, v, xxi, yyi, zzi, "nearest"); |
15333
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
223 %! assert (vi, vi2); |
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
224 |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
225 %!test # vector xi, yi, zi |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
226 %! x = z = 1:2; y = 1:3; |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
227 %! v = ones ([3,2,2]); v(:,2,1) = [7;5;4]; v(:,1,2) = [2;3;5]; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
228 %! xi = zi = .6:1.6; yi = 1; |
15333
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
229 %! vi = interp3 (x, y, z, v, xi, yi, zi, "nearest"); |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
230 %! vi2 = interpn (y, x, z, v, yi, xi, zi, "nearest"); |
15333
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
231 %! assert (vi, vi2); |
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
232 |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
233 %!test # vector xi+1 with extrap value |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
234 %! x = z = 1:2; y = 1:3; |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
235 %! v = ones ([3,2,2]); v(:,2,1) = [7;5;4]; v(:,1,2) = [2;3;5]; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
236 %! xi = zi = .6:1.6; yi = 1; |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
237 %! vi = interp3 (x, y, z, v, xi+1, yi, zi, "nearest", 3); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
238 %! vi2 = interpn (y, x, z, v, yi, xi+1, zi, "nearest", 3); |
15333
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
239 %! assert (vi, vi2); |
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
240 |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
241 %!test # input value matrix--no x,y,z |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
242 %! x = z = 1:2; y = 1:3; |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
243 %! v = ones ([3,2,2]); v(:,2,1) = [7;5;4]; v(:,1,2) = [2;3;5]; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
244 %! xi = zi = .6:1.6; yi = 1; |
15333
7d2eb4a01798
fix problem in interp3.m when method argument is passed, added tests, and made one test more stringent
Kris Thielemans <kris.f.thielemans@gmail.com>
parents:
14363
diff
changeset
|
245 %! vi = interp3 (v, xi, yi, zi, "nearest"); |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
246 %! vi2 = interpn (v, yi, xi, zi, "nearest"); |
6702 | 247 %! assert (vi, vi2); |
13151 | 248 |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
249 %!test # input value matrix--no x,y,z, with extrap value |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
250 %! x = z = 1:2; y = 1:3; |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
251 %! v = ones ([3,2,2]); v(:,2,1) = [7;5;4]; v(:,1,2) = [2;3;5]; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
252 %! xi = zi = .6:1.6; yi = 1; |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
253 %! vi = interp3 (v, xi, yi, zi, "nearest", 3); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
254 %! vi2 = interpn (v, yi, xi, zi, "nearest", 3); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
255 %! assert (vi, vi2); |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
256 |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
257 %!test # extrapolation |
28892
3cac3ceb9629
maint: Use coding style with parentheses after function name to distinguish from a variable.
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
258 %! X = [0,0.5,1]; Y=X; Z=X; |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
259 %! V = zeros (3,3,3); |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
260 %! V(:,:,1) = [1 3 5; 3 5 7; 5 7 9]; |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
261 %! V(:,:,2) = V(:,:,1) + 2; |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
262 %! V(:,:,3) = V(:,:,2) + 2; |
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
263 %! tol = 10 * eps; |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
264 %! x = y = z = [-0.1,0,0.1]; |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
265 %! assert (interp3 (X,Y,Z,V,x,y,z,"spline"), [-0.2, 1.0, 2.2], tol); |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
266 %! assert (interp3 (X,Y,Z,V,x,y,z,"linear"), [NA, 1.0, 2.2], tol); |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
267 %! assert (interp3 (X,Y,Z,V,x,y,z,"spline", 0), [0, 1.0, 2.2], tol); |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
268 %! assert (interp3 (X,Y,Z,V,x,y,z,"linear", 0), [0, 1.0, 2.2], tol); |
19658
5a59c0e1203d
Modified the "extrap" option for interp2, interp3, and interpn (bug #44002).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
19597
diff
changeset
|
269 |
13151 | 270 %!shared z, zout, tol |
271 %! z = zeros (3, 3, 3); | |
272 %! zout = zeros (5, 5, 5); | |
273 %! z(:,:,1) = [1 3 5; 3 5 7; 5 7 9]; | |
274 %! z(:,:,2) = z(:,:,1) + 2; | |
275 %! z(:,:,3) = z(:,:,2) + 2; | |
276 %! for n = 1:5 | |
277 %! zout(:,:,n) = [1 2 3 4 5; | |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
278 %! 2 3 4 5 6; |
13151 | 279 %! 3 4 5 6 7; |
280 %! 4 5 6 7 8; | |
281 %! 5 6 7 8 9] + (n-1); | |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
282 %! endfor |
13151 | 283 %! tol = 10 * eps; |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
284 %! |
13151 | 285 %!assert (interp3 (z), zout, tol) |
286 %!assert (interp3 (z, "linear"), zout, tol) | |
287 %!assert (interp3 (z, "spline"), zout, tol) | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14359
diff
changeset
|
288 |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
289 %!test <*57450> |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
290 %! [x, y, z] = meshgrid (1:10); |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
291 %! v = x; |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
292 %! xi = yi = zi = linspace (1, 10, 20).'; |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
293 %! vi = interp3 (x, y, z, v, xi, yi, zi); |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
294 %! assert (size (vi), [20, 1]); |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
295 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19795
diff
changeset
|
296 ## Test input validation |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
297 %!error <not enough input arguments> interp3 () |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
298 %!error <Invalid call> interp3 ({1}) |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
299 %!error <EXTRAPVAL must be a numeric scalar> interp3 (1,2,3,4,1,2,3,"linear", {1}) |
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
300 %!error <EXTRAPVAL must be a numeric scalar> interp3 (1,2,3,4,1,2,3,"linear", ones (2,2)) |
18587
5cf9a02732b6
Issue warning when '*' flag used with interp2,3,n.m (bug #41459).
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
301 %!warning <ignoring unsupported '\*' flag> interp3 (rand (3,3,3), 1, "*linear"); |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
302 %!error <V must be a 3-D array> interp3 (ones (2,2)) |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
303 %!error <V must be a 3-D array> interp3 (ones (2,2), 1,1,1) |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
304 %!error <XI, YI, and ZI dimensions must be equal> interp3 (ones (2,2,2), 1,1, ones (2,2)) |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
305 %!error <V must be a 3-D array> interp3 (1:2, 1:2, 1:2, ones (2,2), 1,1,1) |
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
306 %!error <X, Y, Z, and V dimensions must be equal> interp3 (ones (1,2,2), ones (2,2,2), ones (2,2,2), ones (2,2,2), 1,1,1) |
18606
0ede4dbb37f1
Overhaul interp1, interp2, interp3 functions.
Rik <rik@octave.org>
parents:
18587
diff
changeset
|
307 %!error <XI, YI, and ZI dimensions must be equal> interp3 (1:2, 1:2, 1:2, rand (2,2,2), 1,1, ones (2,2)) |
27854
a57e88065f89
interp3.m: Fix orientation of output (bug #57450).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
308 %!error <wrong number .* input arguments> interp3 (1:2, 1:2, 1:2) |