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); |
|
148 if (method(1) == "*") |
|
149 dx = x(2) - x(1); |
|
150 maxx = minx + (ny-1)*dx; |
|
151 else |
|
152 maxx = x(nx); |
|
153 endif |
5838
|
154 |
|
155 if (! pp) |
|
156 if (ischar (extrap) && strcmp (extrap, "extrap")) |
|
157 range = 1:size (xi, 1); |
|
158 yi = zeros (size (xi, 1), size (y, 2)); |
5837
|
159 else |
5838
|
160 range = find (xi >= minx & xi <= maxx); |
|
161 yi = extrap * ones (size (xi, 1), size (y, 2)); |
|
162 if (isempty (range)) |
|
163 if (! isvector (y) && length (szx) == 2 |
|
164 && (szx(1) == 1 || szx(2) == 1)) |
5837
|
165 if (szx(1) == 1) |
|
166 yi = reshape (yi, [szx(2), szy(2:end)]); |
|
167 else |
|
168 yi = reshape (yi, [szx(1), szy(2:end)]); |
|
169 endif |
|
170 else |
|
171 yi = reshape (yi, [szx, szy(2:end)]); |
|
172 endif |
|
173 return; |
|
174 endif |
|
175 xi = xi(range); |
|
176 endif |
|
177 endif |
|
178 |
5838
|
179 if (strcmp (method, "nearest")) |
5837
|
180 if (pp) |
5838
|
181 yi = mkpp ([x(1); (x(1:end-1)+x(2:end))/2; x(end)], y, szy(2:end)); |
5837
|
182 else |
5838
|
183 idx = lookup (0.5*(x(1:nx-1)+x(2:nx)), xi) + 1; |
5837
|
184 yi(range,:) = y(idx,:); |
|
185 endif |
5838
|
186 elseif (strcmp (method, "*nearest")) |
5837
|
187 if (pp) |
5838
|
188 yi = mkpp ([minx; minx+[0.5:(ny-1)]'*dx; maxx], y, szy(2:end)); |
5837
|
189 else |
5838
|
190 idx = max (1, min (ny, floor((xi-minx)/dx+1.5))); |
5837
|
191 yi(range,:) = y(idx,:); |
|
192 endif |
5838
|
193 elseif (strcmp (method, "linear")) |
5837
|
194 dy = y(2:ny,:) - y(1:ny-1,:); |
|
195 dx = x(2:nx) - x(1:nx-1); |
|
196 if (pp) |
5838
|
197 yi = mkpp (x, [dy./dx, y(1:end-1)], szy(2:end)); |
5837
|
198 else |
|
199 ## find the interval containing the test point |
5838
|
200 idx = lookup (x(2:nx-1), xi)+1; |
5837
|
201 # 2:n-1 so that anything beyond the ends |
|
202 # gets dumped into an interval |
|
203 ## use the endpoints of the interval to define a line |
|
204 s = (xi - x(idx))./dx(idx); |
|
205 yi(range,:) = s(:,ones(1,nc)).*dy(idx,:) + y(idx,:); |
|
206 endif |
5838
|
207 elseif (strcmp (method, "*linear")) |
5837
|
208 if (pp) |
|
209 dy = [y(2:ny,:) - y(1:ny-1,:)]; |
5838
|
210 yi = mkpp (minx + [0:ny-1]*dx, [dy./dx, y(1:end-1)], szy(2:end)); |
5837
|
211 else |
|
212 ## find the interval containing the test point |
|
213 t = (xi - minx)/dx + 1; |
|
214 idx = max(1,min(ny,floor(t))); |
|
215 |
|
216 ## use the endpoints of the interval to define a line |
|
217 dy = [y(2:ny,:) - y(1:ny-1,:); y(ny,:) - y(ny-1,:)]; |
|
218 s = t - idx; |
|
219 yi(range,:) = s(:,ones(1,nc)).*dy(idx,:) + y(idx,:); |
|
220 endif |
5838
|
221 elseif (strcmp (method, "pchip") || strcmp (method, "*pchip")) |
5837
|
222 if (nx == 2 || method(1) == "*") |
5838
|
223 x = linspace (minx, maxx, ny); |
5837
|
224 endif |
|
225 ## Note that pchip's arguments are transposed relative to interp1 |
|
226 if (pp) |
5838
|
227 yi = pchip (x.', y.'); |
5837
|
228 yi.d = szy(2:end); |
|
229 else |
5838
|
230 yi(range,:) = pchip (x.', y.', xi.').'; |
5837
|
231 endif |
|
232 |
5838
|
233 elseif (strcmp (method, "cubic") || (strcmp (method, "*cubic") && pp)) |
5837
|
234 ## FIXME Is there a better way to treat pp return return and *cubic |
5838
|
235 if (method(1) == "*") |
|
236 x = linspace (minx, maxx, ny).'; |
5837
|
237 nx = ny; |
|
238 endif |
|
239 |
|
240 if (nx < 4 || ny < 4) |
|
241 error ("interp1: table too short"); |
|
242 endif |
5838
|
243 idx = lookup (x(3:nx-2), xi) + 1; |
5837
|
244 |
|
245 ## Construct cubic equations for each interval using divided |
|
246 ## differences (computation of c and d don't use divided differences |
|
247 ## but instead solve 2 equations for 2 unknowns). Perhaps |
|
248 ## reformulating this as a lagrange polynomial would be more efficient. |
5838
|
249 i = 1:nx-3; |
|
250 J = ones (1, nc); |
|
251 dx = diff (x); |
5837
|
252 dx2 = x(i+1).^2 - x(i).^2; |
|
253 dx3 = x(i+1).^3 - x(i).^3; |
5838
|
254 a = diff (y, 3)./dx(i,J).^3/6; |
|
255 b = (diff (y(1:nx-1,:), 2)./dx(i,J).^2 - 6*a.*x(i+1,J))/2; |
|
256 c = (diff (y(1:nx-2,:), 1) - a.*dx3(:,J) - b.*dx2(:,J))./dx(i,J); |
|
257 d = y(i,:) - ((a.*x(i,J) + b).*x(i,J) + c).*x(i,J); |
5837
|
258 |
|
259 if (pp) |
|
260 xs = [x(1);x(3:nx-2)]; |
|
261 yi = mkpp ([x(1);x(3:nx-2);x(nx)], |
|
262 [a(:), (b(:) + 3.*xs(:,J).*a(:)), ... |
|
263 (c(:) + 2.*xs(:,J).*b(:) + 3.*xs(:,J)(:).^2.*a(:)), ... |
|
264 (d(:) + xs(:,J).*c(:) + xs(:,J).^2.*b(:) + ... |
|
265 xs(:,J).^3.*a(:))], szy(2:end)); |
|
266 else |
|
267 yi(range,:) = ((a(idx,:).*xi(:,J) + b(idx,:)).*xi(:,J) ... |
|
268 + c(idx,:)).*xi(:,J) + d(idx,:); |
|
269 endif |
5838
|
270 elseif (strcmp (method, "*cubic")) |
5837
|
271 if (nx < 4 || ny < 4) |
|
272 error ("interp1: table too short"); |
|
273 endif |
|
274 |
|
275 ## From: Miloje Makivic |
|
276 ## http://www.npac.syr.edu/projects/nasa/MILOJE/final/node36.html |
|
277 t = (xi - minx)/dx + 1; |
5838
|
278 idx = max (min (floor (t), ny-2), 2); |
5837
|
279 t = t - idx; |
|
280 t2 = t.*t; |
|
281 tp = 1 - 0.5*t; |
|
282 a = (1 - t2).*tp; |
|
283 b = (t2 + t).*tp; |
|
284 c = (t2 - t).*tp/3; |
|
285 d = (t2 - 1).*t/6; |
5838
|
286 J = ones (1, nc); |
5837
|
287 |
|
288 yi(range,:) = a(:,J) .* y(idx,:) + b(:,J) .* y(idx+1,:) ... |
|
289 + c(:,J) .* y(idx-1,:) + d(:,J) .* y(idx+2,:); |
|
290 |
5838
|
291 elseif (strcmp (method, "spline") || strcmp (method, "*spline")) |
5837
|
292 if (nx == 2 || method(1) == "*") |
|
293 x = linspace(minx, maxx, ny); |
|
294 endif |
|
295 ## Note that spline's arguments are transposed relative to interp1 |
|
296 if (pp) |
5838
|
297 yi = spline (x.', y.'); |
5837
|
298 yi.d = szy(2:end); |
|
299 else |
5838
|
300 yi(range,:) = spline (x.', y.', xi.').'; |
5837
|
301 endif |
|
302 else |
5838
|
303 error ("interp1: invalid method '%s'", method); |
5837
|
304 endif |
|
305 |
5838
|
306 if (! pp) |
|
307 if (! isvector (y) && length (szx) == 2 && (szx(1) == 1 || szx(2) == 1)) |
5837
|
308 if (szx(1) == 1) |
|
309 yi = reshape (yi, [szx(2), szy(2:end)]); |
|
310 else |
|
311 yi = reshape (yi, [szx(1), szy(2:end)]); |
|
312 endif |
|
313 else |
|
314 yi = reshape (yi, [szx, szy(2:end)]); |
|
315 endif |
|
316 endif |
|
317 |
|
318 endfunction |
|
319 |
|
320 %!demo |
|
321 %! xf=0:0.05:10; yf = sin(2*pi*xf/5); |
|
322 %! xp=0:10; yp = sin(2*pi*xp/5); |
|
323 %! lin=interp1(xp,yp,xf,"linear"); |
|
324 %! spl=interp1(xp,yp,xf,"spline"); |
|
325 %! cub=interp1(xp,yp,xf,"pchip"); |
|
326 %! near=interp1(xp,yp,xf,"nearest"); |
|
327 %! plot(xf,yf,";original;",xf,near,";nearest;",xf,lin,";linear;",... |
|
328 %! xf,cub,";pchip;",xf,spl,";spline;",xp,yp,"*;;"); |
|
329 %! %-------------------------------------------------------- |
|
330 %! % confirm that interpolated function matches the original |
|
331 |
|
332 %!demo |
|
333 %! xf=0:0.05:10; yf = sin(2*pi*xf/5); |
|
334 %! xp=0:10; yp = sin(2*pi*xp/5); |
|
335 %! lin=interp1(xp,yp,xf,"*linear"); |
|
336 %! spl=interp1(xp,yp,xf,"*spline"); |
|
337 %! cub=interp1(xp,yp,xf,"*cubic"); |
|
338 %! near=interp1(xp,yp,xf,"*nearest"); |
|
339 %! plot(xf,yf,";*original;",xf,near,";*nearest;",xf,lin,";*linear;",... |
|
340 %! xf,cub,";*cubic;",xf,spl,";*spline;",xp,yp,"*;;"); |
|
341 %! %-------------------------------------------------------- |
|
342 %! % confirm that interpolated function matches the original |
|
343 |
|
344 %!shared xp, yp, xi, style |
|
345 %! xp=0:5; yp = sin(2*pi*xp/5); |
|
346 %! xi = sort([-1, max(xp)*rand(1,6), max(xp)+1]); |
|
347 |
|
348 %!test style = "nearest"; |
|
349 %!assert (interp1(xp, yp, [min(xp)-1, max(xp)+1]), [NaN, NaN]); |
|
350 %!assert (interp1(xp,yp,xp,style), yp, 100*eps); |
|
351 %!assert (interp1(xp,yp,xp',style), yp', 100*eps); |
|
352 %!assert (interp1(xp',yp',xp',style), yp', 100*eps); |
|
353 %!assert (interp1(xp',yp',xp,style), yp, 100*eps); |
|
354 %!assert (isempty(interp1(xp',yp',[],style))); |
|
355 %!assert (isempty(interp1(xp,yp,[],style))); |
|
356 %!assert (interp1(xp,[yp',yp'],xi(:),style),... |
|
357 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); |
|
358 %!assert (interp1(xp,[yp',yp'],xi,style), |
|
359 %! interp1(xp,[yp',yp'],xi,["*",style])); |
|
360 |
|
361 %!test style = "linear"; |
|
362 %!assert (interp1(xp, yp, [-1, max(xp)+1]), [NaN, NaN]); |
|
363 %!assert (interp1(xp,yp,xp,style), yp, 100*eps); |
|
364 %!assert (interp1(xp,yp,xp',style), yp', 100*eps); |
|
365 %!assert (interp1(xp',yp',xp',style), yp', 100*eps); |
|
366 %!assert (interp1(xp',yp',xp,style), yp, 100*eps); |
|
367 %!assert (isempty(interp1(xp',yp',[],style))); |
|
368 %!assert (isempty(interp1(xp,yp,[],style))); |
|
369 %!assert (interp1(xp,[yp',yp'],xi(:),style),... |
|
370 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); |
|
371 %!assert (interp1(xp,[yp',yp'],xi,style), |
|
372 %! interp1(xp,[yp',yp'],xi,["*",style]),100*eps); |
|
373 |
|
374 %!test style = "cubic"; |
|
375 %!assert (interp1(xp, yp, [-1, max(xp)+1]), [NaN, NaN]); |
|
376 %!assert (interp1(xp,yp,xp,style), yp, 100*eps); |
|
377 %!assert (interp1(xp,yp,xp',style), yp', 100*eps); |
|
378 %!assert (interp1(xp',yp',xp',style), yp', 100*eps); |
|
379 %!assert (interp1(xp',yp',xp,style), yp, 100*eps); |
|
380 %!assert (isempty(interp1(xp',yp',[],style))); |
|
381 %!assert (isempty(interp1(xp,yp,[],style))); |
|
382 %!assert (interp1(xp,[yp',yp'],xi(:),style),... |
|
383 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); |
|
384 %!assert (interp1(xp,[yp',yp'],xi,style), |
|
385 %! interp1(xp,[yp',yp'],xi,["*",style]),1000*eps); |
|
386 |
|
387 %!test style = "spline"; |
|
388 %!assert (interp1(xp, yp, [-1, max(xp) + 1]), [NaN, NaN]); |
|
389 %!assert (interp1(xp,yp,xp,style), yp, 100*eps); |
|
390 %!assert (interp1(xp,yp,xp',style), yp', 100*eps); |
|
391 %!assert (interp1(xp',yp',xp',style), yp', 100*eps); |
|
392 %!assert (interp1(xp',yp',xp,style), yp, 100*eps); |
|
393 %!assert (isempty(interp1(xp',yp',[],style))); |
|
394 %!assert (isempty(interp1(xp,yp,[],style))); |
|
395 %!assert (interp1(xp,[yp',yp'],xi(:),style),... |
|
396 %! [interp1(xp,yp,xi(:),style),interp1(xp,yp,xi(:),style)]); |
|
397 %!assert (interp1(xp,[yp',yp'],xi,style), |
|
398 %! interp1(xp,[yp',yp'],xi,["*",style]),10*eps); |
|
399 |
|
400 %!# test linear extrapolation |
|
401 %!assert (interp1([1:5],[3:2:11],[0,6],"linear","extrap"), [1, 13], eps); |
|
402 %!assert (interp1(xp, yp, [-1, max(xp)+1],"linear",5), [5, 5]); |
|
403 |
|
404 %!error interp1 |
|
405 %!error interp1(1:2,1:2,1,"bogus") |
|
406 |
|
407 %!error interp1(1,1,1, "nearest"); |
|
408 %!assert (interp1(1:2,1:2,1.4,"nearest"),1); |
|
409 %!error interp1(1,1,1, "linear"); |
|
410 %!assert (interp1(1:2,1:2,1.4,"linear"),1.4); |
|
411 %!error interp1(1:3,1:3,1, "cubic"); |
|
412 %!assert (interp1(1:4,1:4,1.4,"cubic"),1.4); |
|
413 %!error interp1(1:2,1:2,1, "spline"); |
|
414 %!assert (interp1(1:3,1:3,1.4,"spline"),1.4); |
|
415 |
|
416 %!error interp1(1,1,1, "*nearest"); |
|
417 %!assert (interp1(1:2:4,1:2:4,1.4,"*nearest"),1); |
|
418 %!error interp1(1,1,1, "*linear"); |
|
419 %!assert (interp1(1:2:4,1:2:4,[0,1,1.4,3,4],"*linear"),[NaN,1,1.4,3,NaN]); |
|
420 %!error interp1(1:3,1:3,1, "*cubic"); |
|
421 %!assert (interp1(1:2:8,1:2:8,1.4,"*cubic"),1.4); |
|
422 %!error interp1(1:2,1:2,1, "*spline"); |
|
423 %!assert (interp1(1:2:6,1:2:6,1.4,"*spline"),1.4); |
|
424 |
|
425 %!assert (ppval(interp1(xp,yp,"nearest","pp"),xi), |
|
426 %! interp1(xp,yp,xi,"nearest","extrap"),10*eps); |
|
427 %!assert (ppval(interp1(xp,yp,"linear","pp"),xi), |
|
428 %! interp1(xp,yp,xi,"linear","extrap"),10*eps); |
|
429 %!assert (ppval(interp1(xp,yp,"cubic","pp"),xi), |
|
430 %! interp1(xp,yp,xi,"cubic","extrap"),10*eps); |
|
431 %!assert (ppval(interp1(xp,yp,"pchip","pp"),xi), |
|
432 %! interp1(xp,yp,xi,"pchip","extrap"),10*eps); |
|
433 %!assert (ppval(interp1(xp,yp,"spline","pp"),xi), |
|
434 %! interp1(xp,yp,xi,"spline","extrap"),10*eps); |
|
435 |
|
436 %!assert (ppval(interp1(xp,yp,"*nearest","pp"),xi), |
|
437 %! interp1(xp,yp,xi,"*nearest","extrap"),10*eps); |
|
438 %!assert (ppval(interp1(xp,yp,"*linear","pp"),xi), |
|
439 %! interp1(xp,yp,xi,"*linear","extrap"),10*eps); |
|
440 %!assert (ppval(interp1(xp,yp,"*cubic","pp"),xi), |
|
441 %! interp1(xp,yp,xi,"*cubic","extrap"),10*eps); |
|
442 %!assert (ppval(interp1(xp,yp,"*pchip","pp"),xi), |
|
443 %! interp1(xp,yp,xi,"*pchip","extrap"),10*eps); |
|
444 %!assert (ppval(interp1(xp,yp,"*spline","pp"),xi), |
|
445 %! interp1(xp,yp,xi,"*spline","extrap"),10*eps); |