MATLAB: Design of a highpass filter with a kaiser window

filtersignal processing

Good day to all.
I hope someone could help me with the following problem:
I have observations of a parameter (concentrations of a pollutant) every 3 hours.The time series covers a total of 4 years.
I want to design a highpass filter with a cut-off frequency of 3 days and a kaiser window with a 2 day transition width.
I know that fir1 and kaiserord are most likely the solution to my problem, but since my background on the subject of signal filtering is limited, I fail to correctly specify the required parameters (fsampl, fcuts etc…).
Any help would be greatly appreciated.
Thank you in advance!
Sakis

Best Answer

I’ve not designed many fir filters, and none recently, so it took a bit of time for me to understand your sampling frequency and filter specifications and express them in ways the filter design function would understand.
This filter appears stable and has the passband I’d expect, so see if this design does what you want. Remember to use filtfilt to avoid phase distortion. Experiment with it if you need to so it filters your data the way you want.
The code:
Ts = 3/24; % Sampling Interval (Day) 3 Hours = 3/24 Days
Fs = 1/Ts; % Sampling Frequency (1/Day)
Fn = Fs/2; % Nyquist Frequency (1/Day)
Fc = 1/3; % Cutoff Frequency (1/Day)
Fp = 1/5; % Passband Frequency (1/Day)
band_edges = [Fp Fc]/Fn; % Normalised Band Edges
mag_vct = [0 1]; % Specify Highpass
sb_att = 0.01; % Stopband Attenuation (dB)
pb_rpl = 0.05; % Passband Ripple (dB)
devs = [sb_att pb_rpl]; % Filter Specifications Vector
[n,Wn,beta,ftype] = kaiserord(band_edges,mag_vct,devs,Fs); % Design Filter
hh = fir1(n,Wn,ftype,kaiser(n+1,beta),'noscale'); % Create Filter
fzv = linspace(0, 1, 1000)*Fn; % Frequency Vector
freqz(hh, 1024, fzv, Fs) % Assess Filter Transfer Function
Note: The transfer function default x-label is ‘Frequency (Hz)’. Here, it is actually ‘Frequency (1/Day)’.