function newdata = PLGlowpass(data,samprate,cutoff,order)
% newdata = PLGlowpass(data,samprate,cutoff,order)
%
% performs a lowpass filtering of the input data
% using an nth order zero phase lag butterworth filter
if nargin==3 order=2; end; % default to 2nd order
% get filter paramters A and B
[B,A] = butter(order,cutoff/(samprate/2)); % perform filtering
newdata = filtfilt(B,A,data);
