I want to know the value of x_0 at specific y_0 using interpolation
2 views (last 30 days)
Show older comments
Ahmad Alhasanat
on 24 Jun 2015
Commented: Star Strider
on 25 Jun 2015
Hello All, I have a strictly monotone vector x and some repeated values of y, and I want to know the value of x_0 at specific y_0 using "interp1" but I face a message "The grid vectors are not strictly monotonic increasing"
for example
x=-2:5;
y=[3 3 8 15 24 35 48 48];
yint=interp1(y,x,9);
0 Comments
Accepted Answer
Star Strider
on 24 Jun 2015
A useful technique for dealing with repeated elements is to add very small amounts to the repeated values. This works for two or more repeated values, and does not introduce significant error:
x=-2:5;
y=[3 3 8 15 24 35 48 48];
dy = diff([0 y]);
inc = (dy==0) .* [1:length(y)]*eps*10;
y = y + inc;
yint=interp1(y,x,9);
This calculates ‘yint’ as 0.143.
5 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements 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!