File Exchange

image thumbnail

ndnanfilter.m

Filter/smoothing of multidimensional data with an specified window function, ignoring NaNs.

5 Downloads

Updated 04 May 2016

View License

NDNANFILTER N-dimensional zero-phase digital filter, ignoring NaNs.

SHORT SYNTAX:
[Y,W] = ndnanfilter(X,HWIN,F);

SHORT INPUT:
X - Multidimensional data with/without NaNs.
HWIN - Window's name (N-D moving average by default: 'rectwin').
F - Vector specifying the semi-width of the window for each dimension.
SHORT OUTPUT:
Y - Filtered/smoothed X data (same size as X!) with zero phase shift.
W - N-dimensional window with central symmetry generated by a special subfunction called NDWIND.

SHORT DESCRIPTION:
This function applies a N-dimensional convolution of X with W, using the MATLAB's IMFILTER or CONVN function, ignoring/interpolating/filling NaNs.

By default, the edges are padded with the values of X at the borders with the PADARRAY MATLAB's function. When PADARRAY is not found, the program performs zero-padding.

SHORT NOTE:
* See the screenshot.

Cite As

Carlos Adrian Vargas Aguilera (2019). ndnanfilter.m (https://www.mathworks.com/matlabcentral/fileexchange/20417-ndnanfilter-m), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (10)

Jon Estrada

E. Cheynet

Chad Greene

Brilliant! This is a well-written function with excellent documentation. It is nearly as fast as imfilter. Thanks for sharing.

Peter Gaube

Nice and fast, versatile and seems to work. Kudos!

Phillip

Works great, wish they would implement NaN ignoring options like this in the stock Matlab filters. Good job!

Bill Horton

2Dimensional hamming! Incrdible!

Fred Duncan

Mat Lab

This is what FEx is all about! Thanks Carlos!

Updates

1.0.0.0

BSD License

1.0.0.0

Fixed bug: ynan = any(inan(:)) instead of any(inan).

1. Fixed small bug with vector input (force F=0 in the second dimension)
2. Small changes in the description above.

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