Interp1 returns NaN for a value
334 views (last 30 days)
I have some data (x,f(x)) where 0<=x<=1 and I have N points. I wish to obtain f for an inteverval [a,b] which is well within the limits of 0 and 1, and on my end point, I get a NaN so some reason. I think my data set goes up from 0.001 to 0.999, and the set I want values for goes between 0.05 and 0.96. There is no extrapolation required.
What's going on exactly?
Chris B on 27 Aug 2022
Moved: Image Analyst on 27 Aug 2022
I ran into an issue where my start and endpoints were NaN. Turns out I was defining my x and xquery values differently. For example, try this code:
xq=[500*10^-1 :2*10^-1: 1100*10^-1];
x ~= xq because you are comparing floats in this case. Change 10^-1 to 10^1 and you'll get x==xq. So if you're getting NaNs, try making your x and xquery both integers and then dividing to get floats afterward.