matlab - Why getting same output from fir filter even after changing the cutoff frequency for acceleration time series data?
问题描述
I have question about filtering.
Currently I am working on pedestrian step detection using an inertial measuring unit (accelerometer/acceleration data). I need to filter my signal at preprocessing level. Could anyone suggest which one will be the best filtration algorithm to get good accuracy? For now I used digital lowpass fir filter with order=2, window size=1.2sec,sampling frequecy=200hz but seems not working. I want to use a lower cutoff frequency. I used 0.03hz and 3hz of cutoff frequecny but I am getting the same result for both cutoff frequencies. I need your guidance or help that how can I proceed. Below, I am attaching the images of filtration result as link at 3hz and 0.03hz respectively and also code that I tried. Could some one suggest me or provide any good filter in matlab and/or how can I work on that?
fir result at 3hz cutoff fir result at 0.03hz cutoff
Fs = 200;
Hd = designfilt('lowpassfir','FilterOrder',2,'CutoffFrequency',0.03, ...
'DesignMethod','window','Window',{@kaiser,1.2},'SampleRate',Fs);
y1 = filter(Hd,norm);
plot(Time,norm,'b', Time, y1,'red')
xlabel('Time (s)')
ylabel('Amplitude')
legend('norm','Filtered Data')
解决方案
I am adding another answer in reply to your followup questions. A rectangular window (or boxcar window) of width T, when used as moving average filter, is a lowpass filter with transfer function magnitude
|H(f)|=(sin(pifT))/(pifT) (1)
as you can verify by doing the Fourier transform. Therefore H(f)=0.707 when fco=0.44/T, and H(f)=0 when f=1/T. So a lowpass filter with cutoff fco can be implemented with a rectangular window with width on the order of 1/fco (specifically .44/fco). When fco=0.03 Hz, width is on the order of 30 s (specifically 15 s). See plot of transfer function of a 30 s-wide window.
How to find the necessary order:
>> Fs=200; Fc=.03;
>> Hd003=designfilt('lowpassfir','CutoffFrequency',Fc,'SampleRate',Fs);
Hd003 = designfilt('lowpassfir', 'PassbandFrequency', .03, 'StopbandFrequency', .1, 'PassbandRipple', 3, 'StopbandAttenuation', 20, 'SampleRate', 200, 'DesignMethod', 'kaiserwin');
>> disp(length(Hd003.Coefficients));
2400
The command Hd003=designfilt(...) above causes the Filter Design Assistant to launch, because designfilt() does not have enough info. In the FDA, specify Order mode = Minimum, Passband freq=0.03, Stopband freq=0.1, passband ripple=3 dB, stopband atten.=20 db, design method=Kaiser window. I chose those frequencies and dB values because a 2nd order Butterworth does equally well. (See figure.) Then click "OK", and control returns to the Matlab command window, which runs 'designfilt' with the specified parameters. Then check the length of the coefficient vector: it is 2400! I.e. the FIR filter order=2399, and the filter is 12 seconds long. This is not practical, and it is totally un-usable on signals as short as your 1.6 second long example.
- This equation for |H(f)| is for continuous time. It is accurate for discrete time also, as long as the sampling rate Fs>=10/T.
推荐阅读
- mysql - 什么类型的列将支持带偏移量的日期时间?
- python - 如何根据每行的内容对文本文件中的行进行分组?
- excel - 有没有办法在 VBA 运行时匹配类属性?
- android - 如何以编程方式将值传递给我的 CustomView?
- php - PHPExcel Csv阅读器设置编码
- html - Django 表单设置表单的名称
- jboss - jndi值不能支持点
- javascript - 如何隐藏不再需要的单选按钮?
- python - MacOs High Sierra 上的 Enthought Canopy Package Manager 错误
- python - TypeError:“str”对象不可调用,我不知道为什么