(MATLAB)fvtool(FilterObject)和fvtool(FilterObject.SOSMatrix)之间的区别

时间:2019-06-10 14:30:39

标签: matlab filtering

我正在设计一个数字滤波器以放大低频,并且我使用了IIR任意幅度。代码如下:

% 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);

在过滤数据时,我没有得到预期的结果。

DataFiltered = sosfilt(Hd.SOSMatrix,Data)

为了验证我出了什么问题,

fvtool(Hd, 'MagnitudeDisplay','Magnitude (dB)', ...
    'NormalizedFrequency','On','Color','White');

fvtool(Hd.SOSMatrix, 'MagnitudeDisplay','Magnitude (dB)', ...
    'NormalizedFrequency','On','Color','White');

并且注意到第二个偏移了+ 35dB,这是用于滤波器的一个。

如果我过滤数据的方式不正确或者幅值的计算方式之间有差异,我似乎不明白我的代码有什么问题。任何信息将不胜感激!

谢谢。

0 个答案:

没有答案