Designing a moving average filter using DESIGNFILT
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Josselin Gautier
el 16 de Ag. de 2018
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 comentarios
Ver también
Categorías
Más información sobre Digital Filter Analysis en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!