From bug-request at octave dot org Sun Jan 29 00:31:36 2006 Subject: freqz fails on FIR filters From: Quentin Spencer To: bug at octave dot org Date: Sun, 29 Jan 2006 00:27:57 -0600 This bug appears to be introduced relatively recently, and is in both 2.1.72 and 2.9.4. With an IIR filter, everything is OK: octave> freqz([1,1],[1,-0.1]); Octave creates a plot as expected. On the other hand, when the filter is FIR, meaning there is only one argument, or the second argument is a scalar, the function fails: octave> freqz([1,1],[1]); error: quotient: nonconformant arguments (op1 is 1x512, op2 is 512x1) error: evaluating binary operator `./' near line 144, column 10 error: evaluating assignment expression near line 144, column 5 error: called from `freqz' in file `/home/quentin/freqz.m' The problem arises because the postpad function appends along the first non-singleton dimension, which creates a column vector rather than a row vector when the input is a scalar. This can be fixed by explicitly specifying the dimension, as in the patch below. -Quentin Index: scripts/signal/freqz.m =================================================================== RCS file: /cvs/octave/scripts/signal/freqz.m,v retrieving revision 1.22 diff -u -r1.22 freqz.m --- scripts/signal/freqz.m 15 Dec 2005 01:16:27 -0000 1.22 +++ scripts/signal/freqz.m 29 Jan 2006 06:25:41 -0000 at @ -131,12 +131,12 @@ ## would be faster to use polyval but in practice the overhead for ## polyval is much higher and the little bit of time saved isn't ## worth the extra code. - hb = fft (postpad (b, n)); - ha = fft (postpad (a, n)); + hb = fft (postpad (b, n, 0, 2)); + ha = fft (postpad (a, n, 0, 2)); else f = Fs/2 * (0:n-1)' / n; - hb = fft (postpad (b, 2*n))(1:n); - ha = fft (postpad (a, 2*n))(1:n); + hb = fft (postpad (b, 2*n, 0, 2))(1:n); + ha = fft (postpad (a, 2*n, 0, 2))(1:n); endif h = hb ./ ha; ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------