octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #36732] interp1 does not check input for monot


From: Ben Abbott
Subject: [Octave-bug-tracker] [bug #36732] interp1 does not check input for monotonicity
Date: Sun, 19 Aug 2012 21:39:45 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.79 Safari/537.1

Follow-up Comment #31, bug #36732 (project octave):

Michael,

I had omitted an important part of the demo


 clf
 xi = [1, 2, 3, 3, 4, 5];
 yi = [1, 2, 2, 4, 4, 5];
 x = 1:0.01:5;
 plot (x, interp1 (xi, yi, x),
       fliplr (x), interp1 (xi, yi, fliplr (x)))


Should this example produce a single curve, or should the ascending curve
produce a different result as compared to the descending curve?

>From comment #24, I had thought you intended that ascending values of x would
use interp1 ([1, 2, 3, 4, 5], [1, 2, 2, 4, 5], x) and descending values of x
would use interp1 ([1, 2, 3, 4, 5], [1, 2, 4, 4, 5], x).

I assume my inference was incorrect.

Regarding the sorting, Matlab does this as well.


interp1 ([1, 3, 2, 5, 4], [1, 3, 2, 5, 4], 1:5)

ans =

     1     2     3     4     5


The language may need rewording, but does the code below do what is needed to
finish your changeset?


 ## check for non-continuous identical values.
  if (any ((diff (x(1:(end-1))) == 0) & (diff (x(2:end)) == 0)))
    error ("interp1: X may not have non-continuous identical values");
  endif


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?36732>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]