% Diary of MATLAB commands for partial fraction expansion. % ELEC 320, R. Kozick >> help roots ROOTS Find polynomial roots. ROOTS(C) computes the roots of the polynomial whose coefficients are the elements of the vector C. If C has N+1 components, the polynomial is C(1)*X^N + ... + C(N)*X + C(N+1). See also POLY, RESIDUE, FZERO. >> roots([1 5 6]) ans = -3 -2 >> help residue RESIDUE Partial-fraction expansion (residues). [R,P,K] = RESIDUE(B,A) finds the residues, poles and direct term of a partial fraction expansion of the ratio of two polynomials B(s)/A(s). If there are no multiple roots, B(s) R(1) R(2) R(n) ---- = -------- + -------- + ... + -------- + K(s) A(s) s - P(1) s - P(2) s - P(n) Vectors B and A specify the coefficients of the numerator and denominator polynomials in descending powers of s. The residues are returned in the column vector R, the pole locations in column vector P, and the direct terms in row vector K. The number of poles is n = length(A)-1 = length(R) = length(P). The direct term coefficient vector is empty if length(B) < length(A), otherwise length(K) = length(B)-length(A)+1. If P(j) = ... = P(j+m-1) is a pole of multplicity m, then the expansion includes terms of the form R(j) R(j+1) R(j+m-1) -------- + ------------ + ... + ------------ s - P(j) (s - P(j))^2 (s - P(j))^m [B,A] = RESIDUE(R,P,K), with 3 input arguments and 2 output arguments, converts the partial fraction expansion back to the polynomials with coefficients in B and A. Warning: Numerically, the partial fraction expansion of a ratio of polynomials represents an ill-posed problem. If the denominator polynomial, A(s), is near a polynomial with multiple roots, then small changes in the data, including roundoff errors, can make arbitrarily large changes in the resulting poles and residues. Problem formulations making use of state-space or zero-pole representations are preferable. See also POLY, ROOTS, DECONV. >> disp('Example 1') Example 1 >> num = [1 17]; >> den = [1 4 -5]; >> roots(den) ans = -5 1 >> [r, p] = residue(num, den) r = -2 3 p = -5 1 >> disp('Example 2') Example 2 >> num = [3 -5]; >> den = [1 3 7 5]; >> [r, p] = residue(num, den) r = 1.0000 - 0.7500i 1.0000 + 0.7500i -2.0000 p = -1.0000 + 2.0000i -1.0000 - 2.0000i -1.0000 >> abs(r) ans = 1.2500 1.2500 2.0000 >> angle(r)/pi*180 ans = -36.8699 36.8699 180.0000 >> disp('Example 3') Example 3 >> num = [16 43]; >> den = [1 4 -3 -18]; >> [r, p] = residue(num, den) r = -3.0000 1.0000 3.0000 p = -3.0000 -3.0000 2.0000 >> disp('Example 4') Example 4 >> num = [1 0 2 -4]; >> den = [1 4 -2]; >> [r, p] = residue(num, den) r = 20.6145 -0.6145 p = -4.4495 0.4495