Where is the problem with these statements related to function 'interp1' with option 'pchip'?
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Ricardo Boza Villar
le 27 Mai 2016
0 votes
Catégories
En savoir plus sur Interpolation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!