Interp1 returns NaN for a value

310 views (last 30 days)
Matthew Hunt
Matthew Hunt on 8 Oct 2019
Commented: dpb on 25 Oct 2021
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?
dpb on 25 Oct 2021
As we told the original poster some two years ago, unless you post the data and the code, there's nothing can do beyond the general suggestions given here then -- interp1 has been around long enough that if there were some actual flaw in it, it is highly unlikely it wouldn't have been found long before now.
Attach the data at a minimum...

Sign in to comment.

Answers (1)

Star Strider
Star Strider on 8 Oct 2019
You could have NaN values in your data. If so, first use the fillmissing function (R2016b and later reseases), then interp1.
Star Strider
Star Strider on 8 Oct 2019
If you are not extrapolating (that should only produce NaN values for the extrapolated values if you do not include a method designation and the 'extrap' argument), and there are no NaN values anywhere in your data, and we can’t see your data to test it, this will likely remain unsolved.

Sign in to comment.



Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!