From bug-octave-request at bevo dot che dot wisc dot edu Tue Dec 3 14:03:05 2002 Subject: Re: odd order butterworth filters From: Paul Kienzle To: Shaun Jackman Cc: bug-octave at bevo dot che dot wisc dot edu Date: Tue, 3 Dec 2002 15:02:54 -0500 Actually, it does support odd order filters. Try: octave:4> [z,p,k] = butter(1,0.5) z = -1 p = 5.5511e-17 + 6.1230e-17i k = 0.50000 The problem is that Octave's zp2tf gets confused by p. You could instead define zp2tf as follows, then butter will work without change: ## usage: [b, a] = zp2tf(z, p, g) ## ## Convert to transfer function f(x)=sum(b*x^n)/sum(a*x^n) from ## zero-pole-gain form f(x)=g*prod(1-z*x)/prod(1-p*x) function [b, a] = zp2tf(z, p, g) if nargin != 3 || nargout != 2 usage("[b, a] = zp2tf(z, p, g)"); endif b = g*poly(z); a = poly(p); # check if the system should be real if ( max(imag([a(:);b(:)])) ./ max(abs([a(:);b(:)])) < 100*eps ) b = real(b); a = real(a); endif endfunction I don't know if this definition of zp2tf is correct for the Octave control systems toolbox. I will change butter, cheby1, cheby2, ellip to use the following form so they will work even with Octave's broken zp2tf: b = real(g*poly(z)); a = real(poly(p)); Paul Kienzle pkienzle at users dot sf dot net On Tue, Dec 03, 2002 at 03:33:43AM -0600, Shaun Jackman wrote: > The butter command doesn't support odd order filters. > >> [b a] = butter( 1, 0.5); > error: invalid matrix index = 1 > error: evaluating assignment expression near line 43, column 9 > error: evaluating if command near line 34, column 3 > error: called from `__zp2ssg2__' in file > `/usr/share/octave/2.1.36/m/control/system/__zp2ssg2__.m' > error: called from `zp2tf' in file > `/usr/share/octave/2.1.36/m/control/system/zp2tf.m' > error: called from `butter' in file > `/usr/share/octave/2.1.36/m/signal/butter.m' > > Thanks! > Shaun > > > > ------------------------------------------------------------- > 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 > ------------------------------------------------------------- > ------------------------------------------------------------- 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 -------------------------------------------------------------