Mercurial > jwe > octave
changeset 29923:8c7685d70cf3
maint: Merge stable to default.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 25 Jul 2021 20:25:47 +0200 |
parents | 0bf14f708dc6 (current diff) 09b36aa7088a (diff) |
children | 4559cdcc4562 |
files | scripts/general/interp1.m |
diffstat | 1 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/interp1.m Fri Jul 23 14:18:00 2021 -0700 +++ b/scripts/general/interp1.m Sun Jul 25 20:25:47 2021 +0200 @@ -126,12 +126,12 @@ extrap = NA; xi = []; ispp = false; - firstnumeric = true; + have_xi = false; rightcontinuous = NaN; if (nargin > 2) - for i = 1:length (varargin) - arg = varargin{i}; + for i_arg = 1:length (varargin) + arg = varargin{i_arg}; if (ischar (arg)) arg = tolower (arg); switch (arg) @@ -147,9 +147,9 @@ method = arg; endswitch else - if (firstnumeric) + if (i_arg == 1) xi = arg; - firstnumeric = false; + have_xi = true; else extrap = arg; endif @@ -157,7 +157,7 @@ endfor endif - if (isempty (xi) && firstnumeric && ! ispp) + if (! have_xi && ! ispp) xi = y; y = x; if (isvector (y)) @@ -524,6 +524,8 @@ %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!assert (interp1 (yp, xi, style, 0), ... +%! interp1 (1:numel (yp), yp, xi, style, 0), 10*eps) %!error interp1 (1,1,1, style) ## ENDBLOCK @@ -561,6 +563,8 @@ #%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!assert (interp1 (yp, xi, style, 0), ... +%! interp1 (1:numel (yp), yp, xi, style, 0), 10*eps) %!error interp1 (1,1,1, style) ## ENDBLOCK @@ -596,6 +600,8 @@ #%! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!assert (interp1 (yp, xi, style, 0), ... +%! interp1 (1:numel (yp), yp, xi, style, 0), 10*eps) %!error interp1 (1,1,1, style) ## ENDBLOCK @@ -631,6 +637,8 @@ %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!assert (interp1 (yp, xi, style, 0), ... +%! interp1 (1:numel (yp), yp, xi, style, 0), 10*eps) %!assert (interp1 ([1 2 2 3], [1 2 3 4], 2), 3) %!assert (interp1 ([3 2 2 1], [4 3 2 1], 2), 2) %!error interp1 (1,1,1, style) @@ -668,6 +676,8 @@ %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),100*eps) +%!assert (interp1 (yp, xi, style, 0), ... +%! interp1 (1:numel (yp), yp, xi, style, 0), 10*eps) %!error interp1 (1,1,1, style) ## ENDBLOCK @@ -703,6 +713,8 @@ %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!assert (interp1 (yp, xi, style, 0), ... +%! interp1 (1:numel (yp), yp, xi, style, 0), 10*eps) %!error interp1 (1,1,1, style) ## ENDBLOCK @@ -738,6 +750,8 @@ %! interp1 (fliplr (xp),fliplr (yp),xi,style),100*eps) %!assert (ppval (interp1 (xp,yp,style,"pp"),xi), %! interp1 (xp,yp,xi,style,"extrap"),10*eps) +%!assert (interp1 (yp, xi, style, 0), ... +%! interp1 (1:numel (yp), yp, xi, style, 0), 10*eps) %!error interp1 (1,1,1, style) ## ENDBLOCK ## ENDBLOCKTEST