Difference between fvtool(FilterObject) and fvtool(FilterObject.SOSMatrix)
조회 수: 6 (최근 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에서 Filter Design에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!