
19th September 2005, 23:58 #1
Full Member level 3
freqz matlab
I am trying to use the freqz function in matlab to plot an FIR filter (coefficient b=[.5 .5 .5 .5])magnitude and phase response. I tried two different method to plot the magnitude, but I got different results. anything wrong?
1) directly use freqz(b,1) , it automatically plot both of magitude in db and phase.
2)I use [h,w]=freqz(b,1)
plot(w, 20*log(abs(h)))
For these two methods, I got different magnitude plot. What's wrong with my code?
I suppose they will get same plot.

19th September 2005, 23:58

20th September 2005, 02:03 #2
Full Member level 4
matlab freqz
The plot is the same. The normalized frequency is what is different in the plots.
In one it is normalized from pi*pi or 0 to pi as it appears.
In the other it is normalized from 0.5 to 0.5 or 0 to 1 as it appears
Either way is correct but take care , once using one approach, keep on this.

20th September 2005, 02:03

21st September 2005, 06:24 #3
Advanced Member level 4
freqz function in matlab
I guess if u add the following line before the plot line they will be the same:
Regards,
amraldo.

21st September 2005, 06:24

21st September 2005, 10:54 #4
Full Member level 4
freqz plot
There is another thing that I didn't quote in the first answer. Typing the commands exactly how you presented, there is also a difference in magnitude in the plots. Actually that was your question.
This is because you did type >> plot(w, 20*log(abs(h)))
you should type >> plot(w, 20*log10(abs(h))) otherwise you are gonna have the Neperian Logarithm and not the base 10 log.
Well, now I think the answer is completed.