comparison scripts/polynomial/spline.m @ 10658:c66a4657d764

spline.m: Ignore NaNs within input vectors.
author Ben Abbott <bpabbott@mac.com>
date Tue, 25 May 2010 18:14:25 -0400
parents 95c3e38098bf
children be55736a0783
comparison
equal deleted inserted replaced
10657:c6833d31f34e 10658:c66a4657d764
91 szy = fliplr (szy); 91 szy = fliplr (szy);
92 endif 92 endif
93 else 93 else
94 a = reshape (y, [prod(szy(1:end-1)), szy(end)]).'; 94 a = reshape (y, [prod(szy(1:end-1)), szy(end)]).';
95 endif 95 endif
96
97 for k = (1:columns (a))(any (isnan (a)))
98 ok = ! isnan (a(:,k));
99 a(!ok,k) = spline (x(ok), a(ok,k), x(!ok));
100 endfor
101
96 complete = false; 102 complete = false;
97 if (size (a, 1) == n + 2) 103 if (size (a, 1) == n + 2)
98 complete = true; 104 complete = true;
99 dfs = a(1,:); 105 dfs = a(1,:);
100 dfe = a(end,:); 106 dfe = a(end,:);
221 %!assert (real(spline(x.',y,x)), real(y), abserr); 227 %!assert (real(spline(x.',y,x)), real(y), abserr);
222 %!assert (imag(spline(x,y,x)), imag(y), abserr); 228 %!assert (imag(spline(x,y,x)), imag(y), abserr);
223 %!assert (imag(spline(x,y,x.')), imag(y).', abserr); 229 %!assert (imag(spline(x,y,x.')), imag(y).', abserr);
224 %!assert (imag(spline(x.',y.',x.')), imag(y).', abserr); 230 %!assert (imag(spline(x.',y.',x.')), imag(y).', abserr);
225 %!assert (imag(spline(x.',y,x)), imag(y), abserr); 231 %!assert (imag(spline(x.',y,x)), imag(y), abserr);
232 %!test
233 %! xnan = 5;
234 %! y(x==xnan) = NaN;
235 %! ok = ! isnan (y);
236 %! assert (spline (x, y, x(ok)), y(ok), abserr);
237 %!test
238 %! ok = ! isnan (y);
239 %! assert (! isnan (spline (x, y, x(!ok))));