File Exchange

image thumbnail

repnan

version 1.0.0.0 (323 KB) by Chad Greene
Replace NaNs in a 1D array by interpolation

13 Downloads

Updated 01 Nov 2014

View License

This function replaces NaN values in a 1D array with interpolated or neighboring values. Interpolation schemes assume data are evenly spaced. This function does not extrapolate.

Syntax
x = repnan(x);
x = repnan(x,method);

Description
x = repnan(x) returns x sans NaNs.

x = repnan(x,method) specifies a method for replacing the original x's NaNs. Methods can be

'linear' (default) performs linear interpolation over missing values in x,
'nearest' performs nearest-neighbor interpolation,
'spline' performs spline interpolation using not-a-knot end conditions,
'pchip' is shape-preserving piecewise cubic interpolation,
'cubic' same as 'pchip',
'v5cubic' cubic convolution via Matlab v5 algorithm
'next' replaces NaN values in x with the next non-NaN value in x,
'previous' replaces NaN values in x with the previous non-NaN value in x,

Comments and Ratings (5)

Ben Cooper

Excellent many thanks

Easy to use but very powerful, thanks!

Sagar

Great function Chad, just used it.

Sagar

MATLAB Release Compatibility
Created with R2012b
Compatible with any release
Platform Compatibility
Windows macOS Linux

repnan/html/