% BUTTERFILT % % [ outdata ] = butterfilt( indata , Fs , Forder , Fcutoff , type ) % % Filters input data using a high- or low-pass butterworth filter of a % specified order. If a bandpass filter is specified, Fcutoff must be a % vector containing the high- and low-pass frequencies, [Flow Fhigh]. % % type = 'bandpass' --> bandpass % type = 'low' --> lowpass % type = 'high' -> highpass function [ outdata ] = butterfilt( indata , Fs , Forder , Fcutoff , type ) %-----filter limit filtlimit = Fcutoff / ( Fs / 2 ) ; %-----calculate filter coeficients if strcmp( type , 'bandpass' ) [ coefB, coefA ] = butter( Forder , filtlimit ); else [ coefB, coefA ] = butter( Forder , filtlimit , type); end %-----filter data outdata = filter( coefB, coefA , indata ); end