フィルターのクリア

Scaling of Filter Coefficients in "fir1" function

4 ビュー (過去 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.
  1 件のコメント
Farshad Bolouri
Farshad Bolouri 2024 年 5 月 30 日
Thank You @Paul !
Makes sense now.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSignal 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