Forums

Simple question about calculating difference equation coefficients

Started by j26 February 6, 2011
In Octave:

octave:13> [a,b]=butter(2,0.4);
octave:14> a
a =

   0.206572083826148   0.413144167652296   0.206572083826148

octave:15> [z,p,g]=butter(2,0.4);
octave:16> z
z =

  -1  -1

So I can see that the difference equation coefficients are a = [1,2,1];
multiplied by a scaling factor.  These correspond to two zeros at -1.  But
working out the math, I think the difference equation coefficients should
be a = [1,-2,1];

(1 - z^-1)(1 - z^-1) = 1 - 2*z^-1 + z^-2

Why is octave telling me that the difference equation coefficient a[1] = 2
instead of -2?
On 02/06/2011 01:38 PM, j26 wrote:
> In Octave: > > octave:13> [a,b]=butter(2,0.4); > octave:14> a > a = > > 0.206572083826148 0.413144167652296 0.206572083826148 > > octave:15> [z,p,g]=butter(2,0.4); > octave:16> z > z = > > -1 -1 > > So I can see that the difference equation coefficients are a = [1,2,1]; > multiplied by a scaling factor. These correspond to two zeros at -1. But > working out the math, I think the difference equation coefficients should > be a = [1,-2,1]; > > (1 - z^-1)(1 - z^-1) = 1 - 2*z^-1 + z^-2 > > Why is octave telling me that the difference equation coefficient a[1] = 2 > instead of -2?
z^2 + 2 * z + 1 = 0 is zero when z = -1, or when z = -1. z^2 - 2 * z + 1 = 0 is zero when z = 1, or when z = 1. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
On 02/06/2011 01:38 PM, j26 wrote:
> In Octave: > > octave:13> [a,b]=butter(2,0.4); > octave:14> a > a = > > 0.206572083826148 0.413144167652296 0.206572083826148 > > octave:15> [z,p,g]=butter(2,0.4); > octave:16> z > z = > > -1 -1 > > So I can see that the difference equation coefficients are a = [1,2,1]; > multiplied by a scaling factor. These correspond to two zeros at -1. But > working out the math, I think the difference equation coefficients should > be a = [1,-2,1]; > > (1 - z^-1)(1 - z^-1) = 1 - 2*z^-1 + z^-2 > > Why is octave telling me that the difference equation coefficient a[1] = 2 > instead of -2?
z^2 + 2 * z + 1 = 0 is zero when z = -1, or when z = -1. z^2 - 2 * z + 1 = 0 is zero when z = 1, or when z = 1. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
The Transfer function in matlab and octave are modelled with
numerator and denominator coefficients being all positives.

H(z) = (bo + b1 z^-1 + b2 z^-2 .....)/(a0 + a1 z^-1 + a2 z^-2 + .....)

So when you want to translate this to time domain (difference equation)
the denominator coefficient signs would change. Work out it is simple
math.

Regards
Bharat
On Feb 6, 10:38&#2013266080;pm, "j26" <ptd26@n_o_s_p_a_m.live.com> wrote:
> In Octave: > > octave:13> [a,b]=butter(2,0.4); > octave:14> a > a = > > &#2013266080; &#2013266080;0.206572083826148 &#2013266080; 0.413144167652296 &#2013266080; 0.206572083826148 > > octave:15> [z,p,g]=butter(2,0.4); > octave:16> z > z = > > &#2013266080; -1 &#2013266080;-1 > > So I can see that the difference equation coefficients are a = [1,2,1]; > multiplied by a scaling factor. &#2013266080;These correspond to two zeros at -1. &#2013266080;But > working out the math, I think the difference equation coefficients should > be a = [1,-2,1]; > > (1 - z^-1)(1 - z^-1)
= (z - 1)(z - 1) = 0 => z = ? Rune