Where is the problem with these statements related to function 'interp1' with option 'pchip'?
3 views (last 30 days)
Show older comments
Ricardo Boza Villar
on 26 May 2016
Answered: Ricardo Boza Villar
on 27 May 2016
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.
0 Comments
Accepted Answer
Walter Roberson
on 26 May 2016
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.
0 Comments
More Answers (1)
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!