cannot use element wise operator in frequency response?

1 回表示 (過去 30 日間)
SimTec
SimTec 2022 年 8 月 24 日
コメント済み: Bruno Luong 2022 年 8 月 24 日
Hi guys,
I am trying to get the requency response of the averaging FIR filter using the element wise operator, code below:
Fs=8e3; % sampling frequency
Fc=170; % cutoff frequency
alpha=1-2*pi*Fc/Fs;
nb=round(log2(1/(1-alpha))); % number of shift to the right correspending to multiplication by alpha
NbPoints=1000;
Ndec=Fs/2/1000;
Fstart=1;
i=1:Ndec*NbPoints;
freq=Fstart*10.^(i/NbPoints);
H_f=(1-alpha)*cos(pi.*freq/Fs)/sqrt(1+(alpha^2)-2*alpha*cos(2*pi.*freq/Fs));
semilogx(freq,20*log10(abs(H_f)))
the problem the H_f provides me only one output and not the vector result. how can I fix this.
  3 件のコメント
SimTec
SimTec 2022 年 8 月 24 日
my bad. I just corrected it.. I still do not get the value of the H_f as a vector
Bruno Luong
Bruno Luong 2022 年 8 月 24 日
The division "/" before sqrt is NOT elemetwise division "./".

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

採用された回答

Abderrahim. B
Abderrahim. B 2022 年 8 月 24 日
Fs=8e3; % sampling frequency
Fc=170; % cutoff frequency
alpha=1-2*pi*Fc/Fs;
nb=round(log2(1/(1-alpha))); % number of shift to the right correspending to multiplication by alpha
NbPoints=1000;
Ndec=Fs/2/1000;
Fstart=1;
i=1:Ndec*NbPoints;
freq=Fstart*10.^(i/NbPoints)
freq = 1×4000
1.0023 1.0046 1.0069 1.0093 1.0116 1.0139 1.0162 1.0186 1.0209 1.0233 1.0257 1.0280 1.0304 1.0328 1.0351 1.0375 1.0399 1.0423 1.0447 1.0471 1.0495 1.0520 1.0544 1.0568 1.0593 1.0617 1.0641 1.0666 1.0691 1.0715
H_f=(1-alpha)*cos(pi.*freq/Fs)./sqrt(1+(alpha^2)-2*alpha*cos(2*pi.*freq/Fs))
H_f = 1×4000
1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000
semilogx(freq,20*log10(abs(H_f)))

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by