why freqz with b [1] is different from freqz with b [1,0]
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
christian Alvarado
am 12 Jun. 2020
Kommentiert: Paul
am 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 [1] and b [1,0]
According to me they should be equivalent because 0 does not affect
Please someone who can explain why
0 Kommentare
Akzeptierte Antwort
Paul
am 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.
3 Kommentare
Paul
am 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
am 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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Digital Filtering finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!