Scaling of Filter Coefficients in "fir1" function
2 次查看(过去 30 天)
显示 更早的评论
Hello Everyone,
I had a quick question.
I was looking through the "fir1" function's implementation to see how the coeffs are being scaled. I came across this function:
function b = scalefilter(b,First_Band,ff,L)
%SCALEFILTER Scale filter to have passband approx. equal to one.
if First_Band
b = b / sum(b); % unity gain at DC
else
if ff(4)==1
% unity gain at Fs/2
f0 = 1;
else
% unity gain at center of first passband
f0 = mean(ff(3:4));
end
b = b / abs( exp(-1i*2*pi*(0:L-1)*(f0/2))*(b.') );
end
end
Since there is no documentation for this particular line, I was curious to know where the following equation comes from:
scalingFactor = 1 / abs( exp(-1i*2*pi*(0:L-1)*(f0/2))*(b.') );
Does anyone know?
0 个评论
采纳的回答
Paul
2024-5-30
编辑:Paul
2024-5-30
For a FIR filter
H(z) = b0 + b1*z^-1 + b2*z^-2 .... + b_n*z^(n-1)
its frequency response is
H(w) = b0 + b1(exp(-1j*w) + b2*exp(-1j*w)^2 + .... b_n*exp(-1j*w)^(n-1)
where w is has units of rad/sample.
The equation of interest is computing abs(H(w0)) where w0 (rad/sample) is the middle of pass band. Recall that on input to fir1 the frequencies are normalized such that Wn = 1 -> w = pi. So if f0, which is derived from Wn, is the middle of the pass band, it's related to w0 by: w0 = pi*f0. I'm not sure why it's coded with a mutliply by 2 followed by a divide by 2. I guess it can be viewed as f0/2 converts the input frequency to cycles/sample and then the multiply by 2*pi converts to rad/sample.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Signal Generation and Preprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!