why freqz with b [1] is different from freqz with b [1,0]

조회 수: 2 (최근 30일)
christian Alvarado
christian Alvarado 2020년 6월 12일
댓글: Paul 2020년 6월 17일
I have the following code:
Function FilterFIR(b)
ww=0:(pi/100):pi;
H=freqz(b,1,ww);
subplot(311);
plot(ww,abs(H));
title('Respuesta en frecuencia');
xlabel('\omega');
ylabel('Amplitud');
subplot(312);
plot(ww,angle(H));
xlabel('\omega');
ylabel('Amplitud');
but I get different answers with b [1] and b [1,0]
According to me they should be equivalent because 0 does not affect
Please someone who can explain why

채택된 답변

Paul
Paul 2020년 6월 13일
They should be equivalent and it appears that they basically are:
>> which freqz -all
C:\Program Files\MATLAB\R2019a\toolbox\signal\signal\freqz.m
>> w=0:(pi/100):pi;
>> h1=freqz(1,1,w);
>> h2=freqz([1 0],1,w);
>> max(abs(h1-h2))
ans =
4.9461e-17
Are you seeing a difference more substantial than this? If so, are you sure you're using freqz from the signal processing toolbox and not some other version on your path?
Frankly, I'm not sure why there's any difference at all based on how freqz works according to its doc page.
  댓글 수: 3
Paul
Paul 2020년 6월 14일
I did a bit more investigating and found that freqz works as follows for the FIR case:
When b = 1, it literally evaluates:
h = 1/1;
But, when b = [1 0], it evaluates:
exp(1i*w)./(exp(1i*w)
That result should, of course, be equal to 1, but for some values of w it doesn't quite equal 1 exactly. Don't know why. But I started a new thread here in case there is interest:
Paul
Paul 2020년 6월 17일
I also want point out that in the general case where length b>2, there is antoher complication. For example if
b = [1 0 0 0]
then freqz computes:
exp(1i*w)^3 / exp(1i*w)^3.
However, the way the numerator is computed (using polyval) is different than the way the denominator is computed (exp(1i*w*3)), which can also result in a small error relative to the expected result.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Digital Filtering에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by