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