Designing a moving average filter using DESIGNFILT
4 次查看(过去 30 天)
显示 更早的评论
Dear ML-community,
I am trying to implement a moving average filter using the DESIGNFILT method to get an according DIGITALFILTER object. I use the following code:
MAFilterSizeInSamps = 18;
MACutOffFrequencyInHz = 24.601; %Compute from transfer function
Filter = designfilt('lowpassfir',...
'DesignMethod','window',...
'FilterOrder',MAFilterSizeInSamps-1,...
'CutoffFrequency',MACutOffFrequencyInHz,...
'Window','rectwin',...
'SampleRate',1000);
b = ones(1,MAFilterSizeInSamps)/MAFilterSizeInSamps;
a = 1;
[b;Filter.Coefficients]
fvtool(Filter,b,a)
As I understand it, this should yield the same filter coefficients as specified in b (all-0.055556). Instead I get the following coefficients:
Columns 1 through 6
0.045501 0.048867 0.051924 0.05463 0.056946 0.05884
Columns 7 through 12
0.060284 0.061259 0.06175 0.06175 0.061259 0.060284
Columns 13 through 18
0.05884 0.056946 0.05463 0.051924 0.048867 0.045501
So I am stuck here, since I think these should be the same filters! But the filter transfer functions say otherwise!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/150589/image.jpeg)
I am grateful for any clues!
Greetings, David
0 个评论
回答(1 个)
Josselin Gautier
2018-8-16
Hi, if you are trying to get a digital filter object to use with filtfilt() I would rather recommend to specify directly the numerator and denominator coefficients b and a, and call directly filtfilt() with them. Otherwise, you might be able to export digital filter object with filter designer or filter builder from Signal Processing toolbox
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Digital Filter Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!