From cdd55940b7a287810e423017c42e7c965815c468 Mon Sep 17 00:00:00 2001 From: Sunil Shetye Date: Wed, 25 Jul 2018 17:32:17 +0530 Subject: code changes by Shashikiran Yadalam during FOSSEE Fellowship 2018 --- macros/residued.sci | 127 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 105 insertions(+), 22 deletions(-) (limited to 'macros/residued.sci') diff --git a/macros/residued.sci b/macros/residued.sci index 182b9ca..9b4a386 100644 --- a/macros/residued.sci +++ b/macros/residued.sci @@ -1,25 +1,108 @@ -function [r,p,f,m]=residued(b,a) +// Copyright (C) 2018 - IIT Bombay - FOSSEE +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +// Author:[insert name] +// Organization: FOSSEE, IIT Bombay +// Email: toolbox@scilab.in -// Finds the partial fraction expansion of filter H(z)= B(z)/A(z). -// Calling Sequence -// [r,p,f,m]=residued(b,a) -// Parameters -// b: Real or complex valued vector or matrix -// a: Real or complex valued vector or matrix -// Description -// This is an Octave function. -// Similar to the "residuez" function. The difference being in the function "residuez", the IIR part (poles p and residues r) is driven in parallel with the FIR part(f) whereas in the function "residued", the IIR part is driven by the output of the FIR part. In signal modeling applications, this structure can be more accurate. -// Examples -// 1. [a,b,c,d]=residued([1 i;3 -4],[1 2; 3 4]) -// a = [ 0.19405 - 1.31377i; 0.08329 + 0.99163i; -0.27734 + 0.32215i] -// b = [ -0.10184 - 1.19167i; -0.10184 + 1.19167i; -2.79632 - 0.00000i] -// c = 1 -// d = [ 1 ; 1 ; 1] +// Function File [r, p, f, m] = residued (b, a) +// Compute the partial fraction expansion (PFE) of filter +// H(z) = B(z)/A(z). In the usual PFE function coderesiduez, the +// IIR part (poles p and residues r) is driven in parallel +// with the FIR part (f). In this variant, the IIR part is driven by +// the output of the FIR part. This structure can be more accurate in +// signal modeling applications. +// +// INPUTS: +// b and a are vectors specifying the digital filter +// H(z) = B(z)/A(z). +//NOTE that the polynomials 'b' and 'a' should have real coefficients(because of the function 'filter' used in polyval) +// +// RETURNED: +// +// r = column vector containing the filter-pole residues +// p = column vector containing the filter poles +// f = row vector containing the FIR part, if any +// m = column vector of pole multiplicities +// +// +// Test cases: +//1. +//B=[1 1 ]; A=[1 -2 1]; +// [r,p,f,m] = residued(B,A); +//r = +// -1 +// 2 +//p = +// 1 +// 1 +// +//f = [](0x0) +//e = +// 1 +// 2 +//2. +//B=[6,2]; A=[1 -2 1]; +//[r,p,k,e]=residued(B,A) +//m = +// 1. +// 2. +// f =[] +// p = +// 1. +// 1. +// r = +// - 2. +// 8. +// + +function [r, p, f, m] = residued(b, a, toler) + + // RESIDUED - return residues, poles, and FIR part of B(z)/A(z) + // + // Let nb = length(b), na = length(a), and N=na-1 = no. of poles. + // If nb