You are now following this Submission
- You will see updates in your followed content feed
- You may receive emails, depending on your communication preferences
One-line logically-indexed call to matlab function "interp1"
Fill nan-holes, fast and easy.
>> x = [1 2 NaN NaN 5 6];
>> naninterp(x)
ans =
1 2 3 4 5 6
Cubic interpolation by default, you should know how to change that :-)
--------------------------------------------------------------------------
function X = naninterp(X)
% Interpolate over NaNs
X(isnan(X)) = interp1(find(~isnan(X)), X(~isnan(X)), find(isnan(X)), 'cubic');
return
--------------------------------------------------------------------------
Cite As
E. Rodriguez (2026). naninterp (https://au.mathworks.com/matlabcentral/fileexchange/8225-naninterp), MATLAB Central File Exchange. Retrieved .
Acknowledgements
Inspired: interp1gap, repnan
General Information
- Version 1.0.0.0 (1.07 KB)
MATLAB Release Compatibility
- Compatible with any release
Platform Compatibility
- Windows
- macOS
- Linux
| Version | Published | Release Notes | Action |
|---|---|---|---|
| 1.0.0.0 | added keywords |
