Where is the problem with these statements related to function 'interp1' with option 'pchip'?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ricardo Boza Villar
am 26 Mai 2016
Beantwortet: Ricardo Boza Villar
am 27 Mai 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 Kommentare
Akzeptierte Antwort
Walter Roberson
am 26 Mai 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 Kommentare
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!