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
--------------------------------------------------------------------------
Citar como
E. Rodriguez (2025). naninterp (https://www.mathworks.com/matlabcentral/fileexchange/8225-naninterp), MATLAB Central File Exchange. Recuperado .
Compatibilidad con la versión de MATLAB
Compatibilidad con las plataformas
Windows macOS LinuxCategorías
- MATLAB > Language Fundamentals > Data Types > Numeric Types > NaNs >
Etiquetas
Agradecimientos
Inspiración para: interp1gap, repnan
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Descubra Live Editor
Cree scripts con código, salida y texto formateado en un documento ejecutable.
Versión | Publicado | Notas de la versión | |
---|---|---|---|
1.0.0.0 | added keywords |