# HG changeset patch # User Markus Mützel # Date 1627237547 -7200 # Node ID 8c7685d70cf322fbd79b8cf270dc83dc370194e2 # Parent 0bf14f708dc67506f1fdc0c1f0d9f6087d999ce5# Parent 09b36aa7088a2f0adf87cb9389748d47c07212fe maint: Merge stable to default. diff -r 0bf14f708dc6 -r 8c7685d70cf3 scripts/general/interp1.m --- 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