Bug in freqz

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug in freqz

Jerry
I just submitted a bug report for a big-ass bug in freqz:


If h is an FIR impulse response, then
freqz(h);
performs as advertised. However,
freqz(h, N);
where N is any number including the default 512 returns incorrect magnitude results. The incorrect result is wrong by a scale factor of 1/N, so that dB plots are low by 20.0 * log10(N). If instead
freqz(h * N, N);
is used, the results are as would be expected if freqz were not broken.


How many years has this been broken? What is the vetting/testing/curating process for Octave?

Jerry
------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: Bug in freqz

martin_helm
Am 06.03.2012 10:40, schrieb Jerry:
> I just submitted a bug report for a big-ass bug in freqz:
>
>
> If h is an FIR impulse response, then
> freqz(h);
> performs as advertised. However,
> freqz(h, N);
>From what I can see when I look at the function freqz this use

freqz(h, N);

is completely wrong for what you want.

The second argument is the denominator parameter and you get exactly
what the function is supposed to give in this case.
The third argument is is the number of frequencies.
So what you want is probably freqz(h, 1, N).


------------------------------------------------------------------------------
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
_______________________________________________
Octave-dev mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/octave-dev
Reply | Threaded
Open this post in threaded view
|

Re: Bug in freqz

.terry.
In reply to this post by Jerry
Jerry wrote
I just submitted a bug report for a big-ass bug in freqz:


If h is an FIR impulse response, then
freqz(h);
performs as advertised. However,
freqz(h, N);
where N is any number including the default 512 returns incorrect magnitude results.
You probably got what you needed, just a little more clarification: If you look at help for freqz you'll see it's designed to give the frequency response of IIR filters. Your particular usage freqz(h, N) tells freqz that you want the frequency response of an IIR filter with transfer function numerator of h and denominator of N. But freqz can also be used for FIR filters, just have to remember that the denominator of an FIR filter's transfer function is 1, i.e. it's a simple polynomial with no denominator term. So, as the previous respondent says, make your second input argument a 1 and you're on your way. The explanation for why it worked when you specified freqz(h) is contained in the help: "If A is omitted, the denominator is assumed to be 1 (this corresponds to a simple FIR filter)."