How Does interp1 Work if the Sample Points are not Monotonic?
Forever I’ve thought that the sample points input to @doc:interp1 have to be distinct AND monotonic. But I just saw on the doc page that distinct is the only requirement.
For example:
matlabRelease
x = [1,3,0,2]; % not monotonic
y = sin(x);
xq = 1.5;
yi = interp1(x,y,xq)
I’m quite surprised by this result.
Does interp1 sort the sample points and reorder the sample values if the sample points are not monotonic?
The same answer is obtained:
isequal(yi,interp1(sort(x),sin(sort(x)),xq))Forever I’ve thought that the sample points input to @doc:interp1 have to be distinct AND monotonic. But I just saw on the doc page that distinct is the only requirement.
For example:
matlabRelease
x = [1,3,0,2]; % not monotonic
y = sin(x);
xq = 1.5;
yi = interp1(x,y,xq)
I’m quite surprised by this result.
Does interp1 sort the sample points and reorder the sample values if the sample points are not monotonic?
The same answer is obtained:
isequal(yi,interp1(sort(x),sin(sort(x)),xq)) Forever I’ve thought that the sample points input to @doc:interp1 have to be distinct AND monotonic. But I just saw on the doc page that distinct is the only requirement.
For example:
matlabRelease
x = [1,3,0,2]; % not monotonic
y = sin(x);
xq = 1.5;
yi = interp1(x,y,xq)
I’m quite surprised by this result.
Does interp1 sort the sample points and reorder the sample values if the sample points are not monotonic?
The same answer is obtained:
isequal(yi,interp1(sort(x),sin(sort(x)),xq)) interp1, montonic, sample points MATLAB Answers — New Questions









