Difference between fvtool(FilterObject) and fvtool(FilterObject.SOSMatrix)
2 次查看(过去 30 天)
显示 更早的评论
I'm designing a digital filter to amplify low frequencies and I'm using the IIR Arbitrary Magnitude for it. The code is presented below:
% Acquisition Frequency
FreqAq = 1024;
% Low Frequency Gain
LFGain = 10^(14.4/20);
% Frequency Intervals
FreqIntv = [2 6 600]/FreqAq;
% Numerator Order
NumOrder = 40;
% Denominator Order
DenOrder = 45;
% Frequency Spectrum
Freq = linspace(0,FreqAq,FreqAq + 1)/FreqAq;
% Amplitude Design
bLF = log(1/LFGain)/(FreqIntv(1) - FreqIntv(2));
aLF = LFGain*exp(bLF*FreqIntv(1));
A = [LFGain*ones(1,find(Freq == FreqIntv(1))),...
aLF*exp(-bLF*Freq(find(Freq == FreqIntv(1)) + 1:find(Freq == FreqIntv(2)))),...
ones(1,find(Freq == FreqIntv(3)) - find(Freq == FreqIntv(2))),...
ones(1,length(Freq) - find(Freq == FreqIntv(3)))];
% Arbitrary response magnitude filter specification object
d = fdesign.arbmag('Nb,Na,F,A',NumOrder,DenOrder,Freq,A);
% Filter Weights
W = [ones(1,find(Freq == FreqIntv(1)))*1 ...
ones(1,length(Freq(find(Freq == FreqIntv(1)) + 1:find(Freq == FreqIntv(2)))))*.1 ...
ones(1,find(Freq == 10/FreqAq,1,'first') - find(Freq == FreqIntv(2)))*1 ones(1,find(Freq == FreqIntv(3)) - find(Freq == 10/FreqAq,1,'first'))...
ones(1,length(Freq) - find(Freq == FreqIntv(3)))*1];
% Filter Design
Hd = design(d, 'iirlpnorm', 'Weights', W, 'Norm', 2, 'DensityFactor',30,...
'SystemObject',true);
When filtering the data I'm not getting what I expected.
DataFiltered = sosfilt(Hd.SOSMatrix,Data)
In order to verify what was wrong I plotted
fvtool(Hd, 'MagnitudeDisplay','Magnitude (dB)', ...
'NormalizedFrequency','On','Color','White');
fvtool(Hd.SOSMatrix, 'MagnitudeDisplay','Magnitude (dB)', ...
'NormalizedFrequency','On','Color','White');
and noticed that the second one is shifted about +35dB, which is the one being used for the filter.
I don't seem to understand what is wrong with my code, if the way I filtered the Data is not correct or if there is any difference between how the magnitude is calculated. Any information would be greatly appreciated!
Thank you in advance.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Analog Filters 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!