Why do I get NaNs when I try interpolating with interp1?
89 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am using interp1 to interpolate my data. But, the function is creating NaNs at the end of my query points (last 2000 points).
interp_co2 = interp1(clean_time_co2, clean_co2, time_common);
I have attached clean_time_co2, clean_co2, time_common, and what my computer has as interp_co2. My original data doesn't have any NaNs, but the interp_co2 does have NaN values, and I don't know why.
Thank you!
0 comentarios
Respuestas (1)
Star Strider
el 7 de Oct. de 2021
It will do that if you atempt to extrapolate without telling interp1 how you want to do it.
Try this —
interp_co2 = interp1(clean_time_co2, clean_co2, time_common, 'linear','extrap');
Choose the appropriate interpolation method. (The default is 'linear' so I assume the same extrapolation method.)
Of course, always be careful about extrapolating, because that assumes knowledge about what the data do beyond the region-of-fit that may not be accurate.
.
2 comentarios
Ver también
Categorías
Más información sobre Interpolation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!