Mercurial > hg > octave-nkf
annotate scripts/general/bicubic.m @ 15202:f3b5cadfd6d5
fix missing semicolons in various .m files
* playaudio.m, accumarray.m, accumdim.m, bicubic.m, narginchk.m,
nargoutchk.m, nthargout.m, image.m, pkg.m, colorbar.m, hdl2struct.m,
legend.m, plotyy.m, private/__go_draw_axes__.m,
private/__print_parse_opts__.m, shrinkfaces.m, pchip.m, polyval.m,
rundemos.m: Fix lines with missing semicolons.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 19 Aug 2012 10:50:40 -0400 |
parents | 5d3a684236b0 |
children | 1c89599167a6 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11589
diff
changeset
|
1 ## Copyright (C) 2005-2012 Hoxide Ma |
5837 | 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. | |
5837 | 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/>. | |
5837 | 18 |
19 ## -*- texinfo -*- | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
20 ## @deftypefn {Function File} {@var{zi} =} bicubic (@var{x}, @var{y}, @var{z}, @var{xi}, @var{yi}, @var{extrapval}) |
5837 | 21 ## |
6653 | 22 ## Return a matrix @var{zi} corresponding to the bicubic |
5838 | 23 ## interpolations at @var{xi} and @var{yi} of the data supplied |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
24 ## as @var{x}, @var{y} and @var{z}. Points outside the grid are set |
8828 | 25 ## to @var{extrapval}. |
5837 | 26 ## |
6702 | 27 ## See @url{http://wiki.woodpecker.org.cn/moin/Octave/Bicubic} |
28 ## for further information. | |
5838 | 29 ## @seealso{interp2} |
5837 | 30 ## @end deftypefn |
31 | |
32 ## Bicubic interpolation method. | |
33 ## Author: Hoxide Ma <hoxide_dirac@yahoo.com.cn> | |
34 | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
35 function zi = bicubic (x, y, z, xi, yi, extrapval, spline_alpha) |
5837 | 36 |
6702 | 37 if (nargin < 1 || nargin > 7) |
5837 | 38 print_usage (); |
39 endif | |
40 | |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14598
diff
changeset
|
41 if (nargin == 7 && isscalar (spline_alpha)) |
11589
b0084095098e
missing semicolons in script files
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
42 a = spline_alpha; |
5837 | 43 else |
44 a = 0.5; | |
45 endif | |
46 | |
6702 | 47 if (nargin < 6) |
48 extrapval = NaN; | |
49 endif | |
50 | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
51 if (isa (x, "single") || isa (y, "single") || isa (z, "single") |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
52 || isa (xi, "single") || isa (yi, "single")) |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
53 myeps = eps ("single"); |
7795
df9519e9990c
Handle single precision eps values
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
54 else |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
55 myeps = eps (); |
7795
df9519e9990c
Handle single precision eps values
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
56 endif |
df9519e9990c
Handle single precision eps values
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
57 |
5838 | 58 if (nargin <= 2) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
59 ## bicubic (z) or bicubic (z, 2) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
60 if (nargin == 1) |
5837 | 61 n = 1; |
62 else | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
63 n = y; |
5837 | 64 endif |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
65 z = x; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
66 x = []; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
67 [rz, cz] = size (z); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
68 s = linspace (1, cz, (cz-1) * pow2 (n) + 1); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
69 t = linspace (1, rz, (rz-1) * pow2 (n) + 1); |
5837 | 70 elseif (nargin == 3) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
71 if (! isvector (x) || ! isvector (y)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
72 error ("bicubic: XI and YI must be vector"); |
5837 | 73 endif |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
74 s = y; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
75 t = z; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
76 z = x; |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
77 [rz, cz] = size (z); |
5837 | 78 elseif (nargin == 5 || nargin == 6) |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
79 [rz, cz] = size (z) ; |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
80 if (isvector (x) && isvector (y)) |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
81 if (rz != length (y) || cz != length (x)) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
82 error ("bicubic: length of X and Y must match the size of Z"); |
5837 | 83 endif |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
84 elseif (size_equal (x, y) && size_equal (x, z)) |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
85 x = x(1,:); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
86 y = y(:,1); |
5837 | 87 else |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
88 error ("bicubic: X, Y and Z must be equal size matrices of same size"); |
5837 | 89 endif |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
90 |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
91 if (all (diff (x) < 0)) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
92 flipx = true; |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
93 x = fliplr (x); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
94 elseif (all (diff (x) > 0)) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
95 flipx = false; |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
96 else |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
14868
diff
changeset
|
97 error ("bicubic:nonmonotonic", "bicubic: X values must be monotonic"); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
98 endif |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
99 if (all (diff (y) < 0)) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
100 flipy = true; |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
101 y = flipud (y); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
102 elseif (all (diff (y) > 0)) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
103 flipy = false; |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
104 else |
15202
f3b5cadfd6d5
fix missing semicolons in various .m files
John W. Eaton <jwe@octave.org>
parents:
14868
diff
changeset
|
105 error ("bicubic:nonmonotonic", "bicubic: Y values must be monotonic"); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
106 endif |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
107 |
8506 | 108 ## Mark values outside the lookup table. |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
109 xfirst_ind = find (xi < x(1)); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
110 xlast_ind = find (xi > x(cz)); |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
111 yfirst_ind = find (yi < y(1)); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
112 ylast_ind = find (yi > y(rz)); |
8506 | 113 ## Set value outside the table preliminary to min max index. |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
114 xi(xfirst_ind) = x(1); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
115 xi(xlast_ind) = x(cz); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
116 yi(yfirst_ind) = y(1); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
117 yi(ylast_ind) = y(rz); |
5837 | 118 |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
119 x = reshape (x, 1, cz); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
120 x(cz) *= 1 + sign (x(cz)) * myeps; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
121 if (x(cz) == 0) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
122 x(cz) = myeps; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
123 endif; |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
124 xi = reshape (xi, 1, length (xi)); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
125 [m, i] = sort ([x, xi]); |
5838 | 126 o = cumsum (i <= cz); |
127 xidx = o(find (i > cz)); | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
128 |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
129 y = reshape (y, rz, 1); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
130 y(rz) *= 1 + sign (y(rz)) * myeps; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
131 if (y(rz) == 0) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
132 y(rz) = myeps; |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
133 endif; |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
134 yi = reshape (yi, length (yi), 1); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
135 [m, i] = sort ([y; yi]); |
5838 | 136 o = cumsum (i <= rz); |
8507 | 137 yidx = o([find(i > rz)]); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
138 |
8506 | 139 ## Set s and t used follow codes. |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
140 s = xidx + ((xi .- x(xidx)) ./ (x(xidx+1) .- x(xidx))); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
141 t = yidx + ((yi - y(yidx)) ./ (y(yidx+1) - y(yidx))); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
142 |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
143 if (flipx) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
144 s = fliplr (s); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
145 endif |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
146 if (flipy) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
147 t = flipud (t); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
148 endif |
5837 | 149 else |
150 print_usage (); | |
151 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
152 |
5837 | 153 if (rz < 3 || cz < 3) |
10635
d1978e7364ad
Print name of function in error() string messages.
Rik <octave@nomad.inbox5.com>
parents:
10549
diff
changeset
|
154 error ("bicubic: Z at least a 3 by 3 matrices"); |
5837 | 155 endif |
156 | |
5838 | 157 inds = floor (s); |
158 d = find (s == cz); | |
159 s = s - floor (s); | |
5837 | 160 inds(d) = cz-1; |
161 s(d) = 1.0; | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
162 |
5837 | 163 d = []; |
5838 | 164 indt = floor (t); |
165 d = find (t == rz); | |
166 t = t - floor (t); | |
5837 | 167 indt(d) = rz-1; |
168 t(d) = 1.0; | |
169 d = []; | |
170 | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
171 p = zeros (size (z) + 2); |
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
172 p(2:rz+1,2:cz+1) = z; |
8507 | 173 p(1,:) = (6*(1-a))*p(2,:) - 3*p(3,:) + (6*a-2)*p(4,:); |
174 p(rz+2,:) = (6*(1-a))*p(rz+1,:) - 3*p(rz,:) + (6*a-2)*p(rz-1,:); | |
175 p(:,1) = (6*(1-a))*p(:,2) - 3*p(:,3) + (6*a-2)*p(:,4); | |
176 p(:,cz+2) = (6*(1-a))*p(:,cz+1) - 3*p(:,cz) + (6*a-2)*p(:,cz-1); | |
5837 | 177 |
8506 | 178 ## Calculte the C1(t) C2(t) C3(t) C4(t) and C1(s) C2(s) C3(s) C4(s). |
8507 | 179 t2 = t.*t; |
180 t3 = t2.*t; | |
5837 | 181 |
8507 | 182 ct0 = -a .* t3 + (2 * a) .* t2 - a .* t ; # -a G0 |
5837 | 183 ct1 = (2-a) .* t3 + (-3+a) .* t2 + 1 ; # F0 - a G1 |
184 ct2 = (a-2) .* t3 + (-2 *a + 3) .* t2 + a .* t ; # F1 + a G0 | |
185 ct3 = a .* t3 - a .* t2; # a G1 | |
8507 | 186 t = []; t2 = []; t3 = []; |
5837 | 187 |
8507 | 188 s2 = s.*s; |
189 s3 = s2.*s; | |
5837 | 190 |
8507 | 191 cs0 = -a .* s3 + (2 * a) .* s2 - a .*s ; # -a G0 |
5837 | 192 cs1 = (2-a) .* s3 + (-3 + a) .* s2 + 1 ; # F0 - a G1 |
193 cs2 = (a-2) .* s3 + (-2 *a + 3) .* s2 + a .*s ; # F1 + a G0 | |
194 cs3 = a .* s3 - a .* s2; # a G1 | |
8507 | 195 s = []; s2 = []; s3 = []; |
5837 | 196 |
197 cs0 = cs0([1,1,1,1],:); | |
198 cs1 = cs1([1,1,1,1],:); | |
199 cs2 = cs2([1,1,1,1],:); | |
200 cs3 = cs3([1,1,1,1],:); | |
201 | |
5838 | 202 lent = length (ct0); |
10859
09144fbb0e36
Fix bug #30400 when bicubic called with small numbers of arguments.
Rik <octave@nomad.inbox5.com>
parents:
10635
diff
changeset
|
203 lens = columns (cs0); |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
204 zi = zeros (lent, lens); |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
205 |
5837 | 206 for i = 1:lent |
207 it = indt(i); | |
208 int = [it, it+1, it+2, it+3]; | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
209 zi(i,:) = ([ct0(i),ct1(i),ct2(i),ct3(i)] |
10549 | 210 * (p(int,inds) .* cs0 + p(int,inds+1) .* cs1 |
211 + p(int,inds+2) .* cs2 + p(int,inds+3) .* cs3)); | |
5837 | 212 endfor |
213 | |
8506 | 214 ## Set points outside the table to extrapval. |
5837 | 215 if (! (isempty (xfirst_ind) && isempty (xlast_ind))) |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
216 zi(:, [xfirst_ind, xlast_ind]) = extrapval; |
5837 | 217 endif |
218 if (! (isempty (yfirst_ind) && isempty (ylast_ind))) | |
11470
eb9e0b597d61
Use common names for variables in documentation and code for a few more m-script files.
Rik <octave@nomad.inbox5.com>
parents:
11149
diff
changeset
|
219 zi([yfirst_ind; ylast_ind], :) = extrapval; |
5837 | 220 endif |
221 | |
222 endfunction | |
223 | |
224 %!demo | |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
225 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
226 %! colormap ("default"); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
227 %! A = [13,-1,12;5,4,3;1,6,2]; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
228 %! x = [0,1,4]+10; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
229 %! y = [-10,-9,-8]; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
230 %! xi = linspace (min (x), max (x), 17); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
231 %! yi = linspace (min (y), max (y), 26)'; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
232 %! mesh (xi, yi, bicubic (x,y,A,xi,yi)); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
233 %! [x,y] = meshgrid (x,y); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
234 %! hold on; plot3 (x(:),y(:),A(:),"b*"); hold off; |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
235 |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
236 %!test |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
237 %! x = linspace (1, -1, 10); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
238 %! [xx, yy] = meshgrid (x); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
239 %! z = cos (6 * xx) + sin (6 * yy); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
240 %! x = linspace (1, -1, 30); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
241 %! [xx2, yy2] = meshgrid (x); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
242 %! z1 = interp2 (xx, yy, z, xx2, yy2, "cubic"); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14598
diff
changeset
|
243 %! z2 = interp2 (fliplr (xx), flipud (yy), fliplr (flipud(z)), |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14598
diff
changeset
|
244 %! fliplr (xx2), flipud (yy2), "cubic"); |
14598
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
245 %! z2 = fliplr (flipud (z2)); |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
246 %! assert (z1, z2, 100 * eps ()) |
0d37fda09415
Allow monotonically decending inputs to bicubic ().
Ben Abbott <bpabbott@mac.com>
parents:
14247
diff
changeset
|
247 |