function mLD = filterMag(mLD,dataMinWL,datCol,xCol,yCol)
%   Function: filterMag
%   Author: Daniel O'Hara
%   Date: 12/6/2015
%   Description: Function to perform a 10m moving window filter over data
%   to remove high-frequency features.

    % Collect x,y values.
    x = mLD(:,xCol);
    y = mLD(:,yCol);
    dx = [0;diff(x,1,1)];
    dy = [0;diff(y,1,1)];
    
    % Get distance and differences between points.
    sq = sqrt(dx.^2+dy.^2);
    disChange = round(mean(sq));
    
    % Calculate and b-values needed for filtering. Current data has a mean
    % difference of 2m, so need 5 cells with b-values of .2.
    if disChange < dataMinWL
        newWin = dataMinWL/disChange;
    else
        newWin = dataMinWL;
    end
    
    % Create parameters and filter data.
    b = (1/newWin)*ones(1,newWin);
    a = 1;
    newVal = filter(b,a,mLD(:,datCol));
    mLD(:,datCol) = newVal;
end