Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

freqz function in MATLAB.

Status
Not open for further replies.

triquent

Full Member level 3
Joined
Oct 13, 2004
Messages
166
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,298
Activity points
1,826
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.
 

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.
 

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;

Regards,
amraldo.
 

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top