Scaling of Filter Coefficients in "fir1" function

조회 수: 2 (최근 30일)
Farshad Bolouri
Farshad Bolouri 2024년 5월 30일
댓글: Farshad Bolouri 2024년 5월 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