Azzera filtri
Azzera filtri

cannot use element wise operator in frequency response?

2 visualizzazioni (ultimi 30 giorni)
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 Commenti
SimTec
SimTec il 24 Ago 2022
my bad. I just corrected it.. I still do not get the value of the H_f as a vector
Bruno Luong
Bruno Luong il 24 Ago 2022
The division "/" before sqrt is NOT elemetwise division "./".

Accedi per commentare.

Risposta accettata

Abderrahim. B
Abderrahim. B il 24 Ago 2022
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)))

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by