5837
|
1 ## Copyright (C) 2000 Paul Kienzle |
|
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 |
|
7 ## the Free Software Foundation; either version 2, or (at your option) |
|
8 ## any later version. |
|
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 |
|
16 ## along with Octave; see the file COPYING. If not, write to the Free |
|
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
18 ## 02110-1301, USA. |
|
19 |
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {@var{yi} =} interp1 (@var{x}, @var{y}, @var{xi}) |
|
22 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, @var{method}) |
|
23 ## @deftypefnx {Function File} {@var{yi} =} interp1 (@dots{}, @var{extrap}) |
|
24 ## @deftypefnx {Function File} {@var{pp} =} interp1 (@dots{}, 'pp') |
|
25 ## |
|
26 ## One-dimensional interpolation. Interpolate @var{y}, defined at the |
|
27 ## points @var{x}, at the points @var{xi}. The sample points @var{x} |
|
28 ## must be strictly monotonic. If @var{y} is an array, treat the columns |
|
29 ## of @var{y} seperately. |
|
30 ## |
|
31 ## Method is one of: |
|
32 ## |
|
33 ## @table @asis |
|
34 ## @item 'nearest' |
|
35 ## Return the nearest neighbour. |
|
36 ## @item 'linear' |
|
37 ## Linear interpolation from nearest neighbours |
|
38 ## @item 'pchip' |
|
39 ## Piece-wise cubic hermite interpolating polynomial |
|
40 ## @item 'cubic' |
|
41 ## Cubic interpolation from four nearest neighbours |
|
42 ## @item 'spline' |
|
43 ## Cubic spline interpolation--smooth first and second derivatives |
|
44 ## throughout the curve |
|
45 ## @end table |
|
46 ## |
|
47 ## Appending '*' to the start of the above method forces @code{interp1} |
|
48 ## to assume that @var{x} is uniformly spaced, and only @code{@var{x} |
|
49 ## (1)} and @code{@var{x} (2)} are referenced. This is usually faster, |
|
50 ## and is never slower. The default method is 'linear'. |
|
51 ## |
|
52 ## If @var{extrap} is the string 'extrap', then extrapolate values beyond |
|
53 ## the endpoints. If @var{extrap} is a number, replace values beyond the |
|
54 ## endpoints with that number. If @var{extrap} is missing, assume NaN. |
|
55 ## |
|
56 ## If the string argument 'pp' is specified, then @var{xi} should not be |
|
57 ## supplied and @code{interp1} returns the piece-wise polynomial that |
|
58 ## can later be used with @code{ppval} to evaluate the interpolation. |
|
59 ## There is an equivalence, such that @code{ppval (interp1 (@var{x}, |
|
60 ## @var{y}, @var{method}, 'pp'), @var{xi}) == interp1 (@var{x}, @var{y}, |
|
61 ## @var{xi}, @var{method}, 'extrap')}. |
|
62 ## |
|
63 ## An example of the use of @code{interp1} is |
|
64 ## |
|
65 ## @example |
|
66 ## @group |
|
67 ## xf=[0:0.05:10]; yf = sin(2*pi*xf/5); |
|
68 ## xp=[0:10]; yp = sin(2*pi*xp/5); |
|
69 ## lin=interp1(xp,yp,xf); |
|
70 ## spl=interp1(xp,yp,xf,'spline'); |
|
71 ## cub=interp1(xp,yp,xf,'cubic'); |
|
72 ## near=interp1(xp,yp,xf,'nearest'); |
|
73 ## plot(xf,yf,';original;',xf,lin,';linear;',xf,spl,';spline;',... |
|
74 ## xf,cub,';cubic;',xf,near,';nearest;',xp,yp,'*;;'); |
|
75 ## @end group |
|
76 ## @end example |
|
77 ## |
|
78 ## @seealso{interpft} |
|
79 ## @end deftypefn |
|
80 |
5838
|
81 ## Author: Paul Kienzle |
|
82 ## Date: 2000-03-25 |
5837
|
83 ## added 'nearest' as suggested by Kai Habel |
|
84 ## 2000-07-17 Paul Kienzle |
|
85 ## added '*' methods and matrix y |
|
86 ## check for proper table lengths |
|
87 ## 2002-01-23 Paul Kienzle |
|
88 ## fixed extrapolation |
|
89 |
5838
|
90 function yi = interp1 (x, y, varargin) |
5837
|
91 |
5838
|
92 if (nargin < 3 || nargin > 6) |
5837
|
93 print_usage (); |
|
94 endif |
|
95 |
|
96 method = "linear"; |
|
97 extrap = NaN; |
|
98 xi = []; |
|
99 pp = false; |
|
100 firstnumeric = true; |
|
101 |
|
102 if (nargin > 2) |
5838
|
103 for i = 1:length (varargin) |
5837
|
104 arg = varargin{i}; |
5838
|
105 if (ischar (arg)) |
5837
|
106 arg = tolower (arg); |
5838
|
107 if (strcmp ("extrap", arg)) |
5837
|
108 extrap = "extrap"; |
5838
|
109 elseif (strcmp ("pp", arg)) |
5837
|
110 pp = true; |
|
111 else |
|
112 method = arg; |
|
113 endif |
|
114 else |
|
115 if (firstnumeric) |
|
116 xi = arg; |
|
117 firstnumeric = false; |
|
118 else |
|
119 extrap = arg; |
|
120 endif |
|
121 endif |
|
122 endfor |
|
123 endif |
|
124 |
|
125 ## reshape matrices for convenience |
|
126 x = x(:); |
5838
|
127 nx = size (x, 1); |
5837
|
128 if (isvector(y) && size (y, 1) == 1) |
5838
|
129 y = y(:); |
5837
|
130 endif |
|
131 ndy = ndims (y); |
5838
|
132 szy = size (y); |
5837
|
133 ny = szy(1); |
|
134 nc = prod (szy(2:end)); |
|
135 y = reshape (y, ny, nc); |
5838
|
136 szx = size (xi); |
5837
|
137 xi = xi(:); |
|
138 |
|
139 ## determine sizes |
|
140 if (nx < 2 || ny < 2) |
5838
|
141 error ("interp1: table too short"); |
5837
|
142 endif |
|
143 |
|
144 ## determine which values are out of range and set them to extrap, |
|
145 ## unless extrap=="extrap" in which case, extrapolate them like we |
|
146 ## should be doing in the first place. |
|
147 minx = x(1); |
6366
|
148 maxx = x(nx); |
|
149 if (minx > maxx) |
|
150 tmp = minx; |
|
151 minx = maxx; |
|
152 maxx = tmp; |
|
153 endif |
5837
|
154 if (method(1) == "*") |
6366
|
155 dx = x(2) - x(1); |
5837
|
156 endif |
5838
|
157 |
|
158 if (! pp) |
|
159 if (ischar (extrap) && strcmp (extrap, "extrap")) |
|
160 range = 1:size (xi, 1); |
|
161 yi = zeros (size (xi, 1), size (y, 2)); |
5837
|
162 else |
5838
|
163 range = find (xi >= minx & xi <= maxx); |
|
164 yi = extrap * ones (size (xi, 1), size (y, 2)); |
|
165 if (isempty (range)) |
|
166 if (! isvector (y) && length (szx) == 2 |
|
167 && (szx(1) == 1 || szx(2) == 1)) |
5837
|
168 if (szx(1) == 1) |
|
169 yi = reshape (yi, [szx(2), szy(2:end)]); |
|
170 else |
|
171 yi = reshape (yi, [szx(1), szy(2:end)]); |
|
172 endif |
|
173 else |
|
174 yi = reshape (yi, [szx, szy(2:end)]); |
|
175 endif |
|
176 return; |
|
177 endif |
|
178 xi = xi(range); |
|
179 endif |
|
180 endif |
|
181 |
5838
|
182 if (strcmp (method, "nearest")) |
5837
|
183 if (pp) |
5838
|
184 yi = mkpp ([x(1); (x(1:end-1)+x(2:end))/2; x(end)], y, szy(2:end)); |
5837
|
185 else |
5838
|
186 idx = lookup (0.5*(x(1:nx-1)+x(2:nx)), xi) + 1; |
5837
|
187 yi(range,:) = y(idx,:); |
|
188 endif |
5838
|
189 elseif (strcmp (method, "*nearest")) |
5837
|
190 if (pp) |
5838
|
191 yi = mkpp ([minx; minx+[0.5:(ny-1)]'*dx; maxx], y, szy(2:end)); |
5837
|
192 else |
5838
|
193 idx = max (1, min (ny, floor((xi-minx)/dx+1.5))); |
5837
|
194 yi(range,:) = y(idx,:); |
|
195 endif |
5838
|
196 elseif (strcmp (method, "linear")) |
5837
|
197 dy = y(2:ny,:) - y(1:ny-1,:); |
|
198 dx = x(2:nx) - x(1:nx-1); |
|
199 if (pp) |
5838
|
200 yi = mkpp (x, [dy./dx, y(1:end-1)], szy(2:end)); |
5837
|
201 else |
|
202 ## find the interval containing the test point |
5838
|
203 idx = lookup (x(2:nx-1), xi)+1; |
5837
|
204 # 2:n-1 so that anything beyond the ends |
|
205 # gets dumped into an interval |
|
206 ## use the endpoints of the interval to define a line |
|
207 s = (xi - x(idx))./dx(idx); |
|
208 yi(range,:) = s(:,ones(1,nc)).*dy(idx,:) + y(idx,:); |
|
209 endif |
5838
|
210 elseif (strcmp (method, "*linear")) |
5837
|
211 if (pp) |
|
212 dy = [y(2:ny,:) - y(1:ny-1,:)]; |
5838
|
213 yi = mkpp (minx + [0:ny-1]*dx, [dy./dx, y(1:end-1)], szy(2:end)); |
5837
|
214 else |
|
215 ## find the interval containing the test point |
|
216 t = (xi - minx)/dx + 1; |
|
217 idx = max(1,min(ny,floor(t))); |
|
218 |
|
219 ## use the endpoints of the interval to define a line |
|
220 dy = [y(2:ny,:) - y(1:ny-1,:); y(ny,:) - y(ny-1,:)]; |
|
221 s = t - idx; |
|
222 yi(range,:) = s(:,ones(1,nc)).*dy(idx,:) + y(idx,:); |
|
223 endif |
5838
|
224 elseif (strcmp (method, "pchip") || strcmp (method, "*pchip")) |
5837
|
225 if (nx == 2 || method(1) == "*") |
5838
|
226 x = linspace (minx, maxx, ny); |
5837
|
227 endif |
|
228 ## Note that pchip's arguments are transposed relative to interp1 |
|
229 if (pp) |
5838
|
230 yi = pchip (x.', y.'); |
5837
|
231 yi.d = szy(2:end); |
|
232 else |
5838
|
233 yi(range,:) = pchip (x.', y.', xi.').'; |
5837
|
234 endif |
|
235 |
5838
|
236 elseif (strcmp (method, "cubic") || (strcmp (method, "*cubic") && pp)) |
5837
|
237 ## FIXME Is there a better way to treat pp return return and *cubic |
5838
|
238 if (method(1) == "*") |
|
239 x = linspace (minx, maxx, ny).'; |
5837
|
240 nx = ny; |
|
241 endif |
|
242 |
|
243 if (nx < 4 || ny < 4) |
|
244 error ("interp1: table too short"); |
|
245 endif |
5838
|
246 idx = lookup (x(3:nx-2), xi) + 1; |
5837
|
247 |
|
248 ## Construct cubic equations for each interval using divided |
|
249 ## differences (computation of c and d don't use divided differences |
|
250 ## but instead solve 2 equations for 2 unknowns). Perhaps |
|
251 ## reformulating this as a lagrange polynomial would be more efficient. |
5838
|
252 i = 1:nx-3; |
|
253 J = ones (1, nc); |
|
254 dx = diff (x); |
5837
|
255 dx2 = x(i+1).^2 - x(i).^2; |
|
256 dx3 = x(i+1).^3 - x(i).^3; |
5838
|
257 a = diff (y, 3)./dx(i,J).^3/6; |
|
258 b = (diff (y(1:nx-1,:), 2)./dx(i,J).^2 - 6*a.*x(i+1,J))/2; |
|
259 c = (diff (y(1:nx-2,:), 1) - a.*dx3(:,J) - b.*dx2(:,J))./dx(i,J); |
|
260 d = y(i,:) - ((a.*x(i,J) + b).*x(i,J) + c).*x(i,J); |
5837
|
261 |
|
262 if (pp) |
|
263 xs = [x(1);x(3:nx-2)]; |
|
264 yi = mkpp ([x(1);x(3:nx-2);x(nx)], |
|
265 [a(:), (b(:) + 3.*xs(:,J).*a(:)), ... |
|
266 (c(:) + 2.*xs(:,J).*b(:) + 3.*xs(:,J)(:).^2.*a(:)), ... |
|
267 (d(:) + xs(:,J).*c(:) + xs(:,J).^2.*b(:) + ... |
|
268 xs(:,J).^3.*a(:))], szy(2:end)); |
|
269 else |
|
270 yi(range,:) = ((a(idx,:).*xi(:,J) + b(idx,:)).*xi(:,J) ... |
|
271 + c(idx,:)).*xi(:,J) + d(idx,:); |
|
272 endif |
5838
|
273 elseif (strcmp (method, "*cubic")) |
5837
|
274 if (nx < 4 || ny < 4) |
|
275 error ("interp1: table too short"); |
|
276 endif |
|
277 |
|
278 ## From: Miloje Makivic |
|
279 ## http://www.npac.syr.edu/projects/nasa/MILOJE/final/node36.html |
|
280 t = (xi - minx)/dx + 1; |
5838
|
281 idx = max (min (floor (t), ny-2), 2); |
5837
|
282 t = t - idx; |
|
283 t2 = t.*t; |
|
284 tp = 1 - 0.5*t; |
|
285 a = (1 - t2).*tp; |
|
286 b = (t2 + t).*tp; |
|
287 c = (t2 - t).*tp/3; |
|
288 d = (t2 - 1).*t/6; |
5838
|
289 J = ones (1, nc); |
5837
|
290 |
|
291 yi(range,:) = a(:,J) .* y(idx,:) + b(:,J) .* y(idx+1,:) ... |
|
292 + c(:,J) .* y(idx-1,:) + d(:,J) .* y(idx+2,:); |
|
293 |
5838
|
294 elseif (strcmp (method, "spline") || strcmp (method, "*spline")) |
5837
|
295 if (nx == 2 || method(1) == "*") |
|
296 x = linspace(minx, maxx, ny); |
|
297 endif |
|
298 ## Note that spline's arguments are transposed relative to interp1 |
|
299 if (pp) |
5838
|
300 yi = spline (x.', y.'); |
5837
|
301 yi.d = szy(2:end); |
|
302 else |
5838
|
303 yi(range,:) = spline (x.', y.', xi.').'; |
5837
|
304 endif |
|
305 else |
5838
|
306 error ("interp1: invalid method '%s'", method); |
5837
|
307 endif |
|
308 |
5838
|
309 if (! pp) |
|
310 if (! isvector (y) && length (szx) == 2 && (szx(1) == 1 || szx(2) == 1)) |
5837
|
311 if (szx(1) == 1) |
|
312 yi = reshape (yi, [szx(2), szy(2:end)]); |
|
313 else |
|
314 yi = reshape (yi, [szx(1), szy(2:end)]); |
|
315 endif |
|
316 else |
|
317 yi = reshape (yi, [szx, szy(2:end)]); |
|
318 endif |
|
319 endif |
|
320 |
|
321 endfunction |
|
322 |
|
323 %!demo |
|
324 %! xf=0:0.05:10; yf = sin(2*pi*xf/5); |
|
325 %! xp=0:10; yp = sin(2*pi*xp/5); |
|
326 %! lin=interp1(xp,yp,xf,"linear"); |
|
327 %! spl=interp1(xp,yp,xf,"spline"); |
|
328 %! cub=interp1(xp,yp,xf,"pchip"); |
|
329 %! near=interp1(xp,yp,xf,"nearest"); |
|
330 %! plot(xf,yf,";original;",xf,near,";nearest;",xf,lin,";linear;",... |
|
331 %! xf,cub,";pchip;",xf,spl,";spline;",xp,yp,"*;;"); |
|
332 %! %-------------------------------------------------------- |
|
333 %! % confirm that interpolated function matches the original |
|
334 |
|
335 %!demo |
|
336 %! xf=0:0.05:10; yf = sin(2*pi*xf/5); |
|
337 %! xp=0:10; yp = sin(2*pi*xp/5); |
|
338 %! lin=interp1(xp,yp,xf,"*linear"); |
|
339 %! spl=interp1(xp,yp,xf,"*spline"); |
|
340 %! cub=interp1(xp,yp,xf,"*cubic"); |
|
341 %! near=interp1(xp,yp,xf,"*nearest"); |
|
342 %! plot(xf,yf,";*original;",xf,near,";*nearest;",xf,lin,";*linear;",... |
|
343 %! xf,cub,";*cubic;",xf,spl,";*spline;",xp,yp,"*;;"); |
|
344 %! %-------------------------------------------------------- |
|
345 %! % confirm that interpolated function matches the original |
|
346 |
|
347 %!shared xp, yp, xi, style |
|
348 %! xp=0:5; yp = sin(2*pi*xp/5); |
|
349 %! xi = sort([-1, max(xp)*rand(1,6), max(xp)+1]); |
|
350 |
|
351 %!test style = "nearest"; |
|
352 %!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1]), [NaN, NaN]); |
|
353 %!assert (interp1(xp,yp,xp,style), yp, 100*eps); |
|
354 %!assert (interp1(xp,yp,xp',style), yp', 100*eps); |
|
355 %!assert (interp1(xp',yp',xp',style), yp', 100*eps); |
|
356 %!assert (interp1(xp',yp',xp,style), yp, 100*eps); |
|
357 %!assert (isempty(interp1(xp',yp',[],style))); |
|
358 %!assert (isempty(interp1(xp,yp,[],style))); |
|
359 %!assert (interp1(xp,[yp',yp'],xi(:),style),... |
|
360 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); |
|
361 %!assert (interp1(xp,[yp',yp'],xi,style), |
|
362 %! interp1(xp,[yp',yp'],xi,["*",style])); |
|
363 |
|
364 %!test style = "linear"; |
|
365 %!assert (interp1(xp, yp, [-1, max(xp)+1]), [NaN, NaN]); |
|
366 %!assert (interp1(xp,yp,xp,style), yp, 100*eps); |
|
367 %!assert (interp1(xp,yp,xp',style), yp', 100*eps); |
|
368 %!assert (interp1(xp',yp',xp',style), yp', 100*eps); |
|
369 %!assert (interp1(xp',yp',xp,style), yp, 100*eps); |
|
370 %!assert (isempty(interp1(xp',yp',[],style))); |
|
371 %!assert (isempty(interp1(xp,yp,[],style))); |
|
372 %!assert (interp1(xp,[yp',yp'],xi(:),style),... |
|
373 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); |
|
374 %!assert (interp1(xp,[yp',yp'],xi,style), |
|
375 %! interp1(xp,[yp',yp'],xi,["*",style]),100*eps); |
|
376 |
|
377 %!test style = "cubic"; |
|
378 %!assert (interp1(xp, yp, [-1, max(xp)+1]), [NaN, NaN]); |
|
379 %!assert (interp1(xp,yp,xp,style), yp, 100*eps); |
|
380 %!assert (interp1(xp,yp,xp',style), yp', 100*eps); |
|
381 %!assert (interp1(xp',yp',xp',style), yp', 100*eps); |
|
382 %!assert (interp1(xp',yp',xp,style), yp, 100*eps); |
|
383 %!assert (isempty(interp1(xp',yp',[],style))); |
|
384 %!assert (isempty(interp1(xp,yp,[],style))); |
|
385 %!assert (interp1(xp,[yp',yp'],xi(:),style),... |
|
386 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); |
|
387 %!assert (interp1(xp,[yp',yp'],xi,style), |
|
388 %! interp1(xp,[yp',yp'],xi,["*",style]),1000*eps); |
|
389 |
|
390 %!test style = "spline"; |
|
391 %!assert (interp1(xp, yp, [-1, max(xp) + 1]), [NaN, NaN]); |
|
392 %!assert (interp1(xp,yp,xp,style), yp, 100*eps); |
|
393 %!assert (interp1(xp,yp,xp',style), yp', 100*eps); |
|
394 %!assert (interp1(xp',yp',xp',style), yp', 100*eps); |
|
395 %!assert (interp1(xp',yp',xp,style), yp, 100*eps); |
|
396 %!assert (isempty(interp1(xp',yp',[],style))); |
|
397 %!assert (isempty(interp1(xp,yp,[],style))); |
|
398 %!assert (interp1(xp,[yp',yp'],xi(:),style),... |
|
399 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); |
|
400 %!assert (interp1(xp,[yp',yp'],xi,style), |
|
401 %! interp1(xp,[yp',yp'],xi,["*",style]),10*eps); |
|
402 |
|
403 %!# test linear extrapolation |
|
404 %!assert (interp1([1:5],[3:2:11],[0,6],"linear","extrap"), [1, 13], eps); |
|
405 %!assert (interp1(xp, yp, [-1, max(xp)+1],"linear",5), [5, 5]); |
|
406 |
|
407 %!error interp1 |
|
408 %!error interp1(1:2,1:2,1,"bogus") |
|
409 |
|
410 %!error interp1(1,1,1, "nearest"); |
|
411 %!assert (interp1(1:2,1:2,1.4,"nearest"),1); |
|
412 %!error interp1(1,1,1, "linear"); |
|
413 %!assert (interp1(1:2,1:2,1.4,"linear"),1.4); |
|
414 %!error interp1(1:3,1:3,1, "cubic"); |
|
415 %!assert (interp1(1:4,1:4,1.4,"cubic"),1.4); |
|
416 %!error interp1(1:2,1:2,1, "spline"); |
|
417 %!assert (interp1(1:3,1:3,1.4,"spline"),1.4); |
|
418 |
|
419 %!error interp1(1,1,1, "*nearest"); |
|
420 %!assert (interp1(1:2:4,1:2:4,1.4,"*nearest"),1); |
|
421 %!error interp1(1,1,1, "*linear"); |
|
422 %!assert (interp1(1:2:4,1:2:4,[0,1,1.4,3,4],"*linear"),[NaN,1,1.4,3,NaN]); |
|
423 %!error interp1(1:3,1:3,1, "*cubic"); |
|
424 %!assert (interp1(1:2:8,1:2:8,1.4,"*cubic"),1.4); |
|
425 %!error interp1(1:2,1:2,1, "*spline"); |
|
426 %!assert (interp1(1:2:6,1:2:6,1.4,"*spline"),1.4); |
|
427 |
|
428 %!assert (ppval(interp1(xp,yp,"nearest","pp"),xi), |
|
429 %! interp1(xp,yp,xi,"nearest","extrap"),10*eps); |
|
430 %!assert (ppval(interp1(xp,yp,"linear","pp"),xi), |
|
431 %! interp1(xp,yp,xi,"linear","extrap"),10*eps); |
|
432 %!assert (ppval(interp1(xp,yp,"cubic","pp"),xi), |
|
433 %! interp1(xp,yp,xi,"cubic","extrap"),10*eps); |
|
434 %!assert (ppval(interp1(xp,yp,"pchip","pp"),xi), |
|
435 %! interp1(xp,yp,xi,"pchip","extrap"),10*eps); |
|
436 %!assert (ppval(interp1(xp,yp,"spline","pp"),xi), |
|
437 %! interp1(xp,yp,xi,"spline","extrap"),10*eps); |
|
438 |
|
439 %!assert (ppval(interp1(xp,yp,"*nearest","pp"),xi), |
|
440 %! interp1(xp,yp,xi,"*nearest","extrap"),10*eps); |
|
441 %!assert (ppval(interp1(xp,yp,"*linear","pp"),xi), |
|
442 %! interp1(xp,yp,xi,"*linear","extrap"),10*eps); |
|
443 %!assert (ppval(interp1(xp,yp,"*cubic","pp"),xi), |
|
444 %! interp1(xp,yp,xi,"*cubic","extrap"),10*eps); |
|
445 %!assert (ppval(interp1(xp,yp,"*pchip","pp"),xi), |
|
446 %! interp1(xp,yp,xi,"*pchip","extrap"),10*eps); |
|
447 %!assert (ppval(interp1(xp,yp,"*spline","pp"),xi), |
|
448 %! interp1(xp,yp,xi,"*spline","extrap"),10*eps); |