function m = meanf( x )
% m = meanf( x )
% 
% Calculates the mean value of the finite elements of a vector x. Same as
% Matlab's build in mean.m, except that it removes Nans and Infs first.

m = mean( x( isfinite( x ) ));