+ Post New Thread

Results 1 to 4 of 4

- 19th September 2005, 23:58 #1

- Join Date
- Oct 2004
- Posts
- 166
- Helped
- 1 / 1
- Points
- 2,414
- Level
- 11

## 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

- Join Date
- Aug 2005
- Location
- Salvador-BA-Brazil
- Posts
- 226
- Helped
- 28 / 28
- Points
- 2,906
- Level
- 12

## 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

- Join Date
- Aug 2004
- Location
- Egypt
- Posts
- 1,185
- Helped
- 145 / 145
- Points
- 9,782
- Level
- 23

## freqz function in matlab

I guess if u add the following line before the plot line they will be the same:

Code:w = w / pi;

amraldo.

- 21st September 2005, 06:24

- 21st September 2005, 10:54 #4

- Join Date
- Aug 2005
- Location
- Salvador-BA-Brazil
- Posts
- 226
- Helped
- 28 / 28
- Points
- 2,906
- Level
- 12

## 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.

+ Post New Thread

Please login