function xf = hlp(h,sp,x) %HLP h-hour Low Pass filter % HLP(H,SP,X) filters the input vector X, at the sampling % rate SP, using a 2nd order lowpass digital Butterworth % filter, allowing ~> h-hour information to be "PASSED" to % the output. All arguments are REQUIRED. SP must be the % sample rate in hours. The MATLAB routine FILTFILT is % used to perform the actual filtering. % % INPUT: h - Period to low-pass (hours) % sp - sampling rate (hours) % x - signal % % OUTPUT: y - h-hour low passed version of input x % % CALL AS: y=hlp(40,sp,x); % for 40-hour low pass % % Brian Blanton, Fall 1998 % if nargin==0 & nargout==0 disp('Call as: y=hlp(H,sample_rate,x);') return end wn=cutoff(sp,h); [b,a] = butter(2,wn); xf = filtfilt(b, a, x);