help-octave
[Top][All Lists]

## Re: interp1 - bug

 From: John W. Eaton Subject: Re: interp1 - bug Date: Sat, 12 Sep 2009 08:04:07 -0400

```On 12-Sep-2009, Søren Hauberg wrote:

| lør, 12 09 2009 kl. 13:41 +0200, skrev Roberto Abuter:
| > I guess it is just a difference in behavior between Matlab and Octave.
| > one can always reshuffle (X,Y) in such a way X becames monotonic.
|
| Is there any particular reason why we are not doing this in 'interp1'?
|
|   [x, idx] = sort (x);
|   y = y (idx);
|
| to 'interp1' ?

Suppose I have a set of points that approximate a circle:

theta = 0:0.2:2*pi;
x = cos(theta);
y = sin(theta);
plot (x, y);

and I want to interpolate between two of these points.  If I leave the
points ordered as they are, I need to pick a range where the
interpolation will make sense.  If I just blindly sort the X and Y
values, I get something that doesn't look a lot like a circle, so
interpolating between two of the points is not likely to give me the
result I'm looking for:

[x, idx] = sort (x);
y = y (idx);
plot (x, y);

jwe

```