Scaling of Filter Coefficients in "fir1" function

4 次查看(过去 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?

采纳的回答

Paul
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 CenterFile Exchange 中查找有关 Signal Generation and Preprocessing 的更多信息

产品


版本

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by