Where is the problem with these statements related to function 'interp1' with option 'pchip'?

1 次查看(过去 30 天)
When I write this on the workspace I get an error:
x=[0 2 8 5 6 8 9 11 12 14 15];
y=[10*ones(1,6) 10.5 15 50 60 85];
s=x(1):0.01:x(end);
ys=interp1(x,y,s,'pchip');
It indicates that the grid vectors are not strictly monotonic increasing. I don't know what the 'grid vectors' refer to, but I suppose it refers to the vector of nodes, 'x', the vector of y values belonging to those nodes, 'y' and the vector of x values (longer than the vector of nodes) where I want to find the values that the interpolant has. 'x' and 's' are strictly monotonic increasing; 'y' isn't. As 'y' could be the reason why the statements don't work as planned, I tried y=[10.001 10.002 10.003 10.004 10.005 10.006 10.5 15 50 60 85], but that hasn't worked either and I keep getting the same error. Changing 'pchip' for 'linear' doesn't keep the same error message from appearing.

采纳的回答

Walter Roberson
Walter Roberson 2016-5-26
You have
x=[0 2 8 5 6 8 9 11 12 14 15];
That is not monotonically increasing: it has an 8 between the 2 and the 5, and then it has another 8 between the 6 and the 9. Perhaps the first 8 is intended to be a 3.

更多回答(1 个)

Ricardo Boza Villar
Oh my, oh my! Thank you

类别

Help CenterFile Exchange 中查找有关 Interpolation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by