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

1 view (last 30 days)
christian Alvarado on 12 Jun 2020
Commented: Paul on 17 Jun 2020
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  and b [1,0]
According to me they should be equivalent because 0 does not affect
Please someone who can explain why

Paul on 13 Jun 2020
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.

christian Alvarado on 13 Jun 2020
I also don't know why the difference (it shouldn't), but thank you very much, as I only saw the graph I thought that the difference was bigger
Paul on 14 Jun 2020
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 on 17 Jun 2020
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.