Computing a running average of a simple 1-D data vector seems simple enough. Indeed, the MATLAB documentation for FILTER happily claims something like:
You can use filter to find a running average without using a for loop. This example finds the running average of a 16-element vector, using a window size of 3:
D = [1:0.2:4]';
windowSize = 3;
F = ones(1,windowSize)/windowSize;
Df = filter(F,1,D);
The result:
For my purposes, there are two annoying things about this result: output point n is the average of input points n-(windowSize-1)..n (i.e. not centered, as evidenced by the horizontal shift) and points to the left of the available data are treated as zeros.
FILTFILT deals with both issues, but has other drawbacks. It's part of the Signal Processing Toolbox, and it doesn't deal well with NaNs (which I'd like excluded from the mean).
Some people on FEX obviously had the same frustrations, but it seems odd to me that something this simple requires custom code. Anything I'm missing here?