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

m = median( x( isfinite( x ) ));