home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / DATAFUN.DI$ / DECONV.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  899 b   |  34 lines

  1. function [q,r]=deconv(b,a)
  2. %DECONV    Deconvolution and polynomial division.
  3. %    [Q,R] = DECONV(B,A) deconvolves vector A out of vector B.  The result
  4. %    is returned in vector Q and the remainder in vector R such that
  5. %    B = conv(Q,A) + R.
  6. %
  7. %    If A and B are vectors of polynomial coefficients, deconvolution
  8. %    is equivalent to polynomial division.  The result of dividing B by
  9. %    A is quotient Q and remainder R.
  10. %
  11. %    See also CONV.
  12.  
  13. %    J.N. Little 2-6-86
  14. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  15.  
  16. [mb,nb] = size(b);
  17. nb = max(mb,nb);
  18. na = length(a);
  19. if na > nb
  20.     q = 0;
  21.     r = b;
  22.     return
  23. end
  24. if a(1)==0
  25.     error('First coefficient of A must be non-zero.')
  26. end
  27. % Deconvolution and polynomial division are the same operations
  28. % as a digital filter's impulse response B(z)/A(z):
  29. q = filter(b, a, [1 zeros(1,nb-na)]);
  30. if mb ~= 1
  31.     q = q(:);
  32. end
  33. r = b - conv(q,a);
  34.