naninterp

One dimensional Interpolation over NaNs.

您现在正在关注此提交

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
--------------------------------------------------------------------------

引用格式

E. Rodriguez (2026). naninterp (https://ww2.mathworks.cn/matlabcentral/fileexchange/8225-naninterp), MATLAB Central File Exchange. 检索时间: .

致谢

启发作品: interp1gap, repnan

一般信息

MATLAB 版本兼容性

  • 兼容任何版本

平台兼容性

  • Windows
  • macOS
  • Linux
版本 已发布 发行说明 Action
1.0.0.0

added keywords