function [b,a] = prony(h, nb ,na)
%PRONY	Prony's method for time-domain IIR filter design.
%	[B,A] = PRONY(H, NB, NA) finds a filter with numerator order
%	NB, denominator order NA, and having the impulse response in
%	vector H.   The IIR filter coefficients are returned in
%	length NB+1 and NA+1 row vectors B and A, ordered in
%	descending powers of Z.
%
%	See also: BUTTER, CHEBY1, CHEBY2, ELLIP, INVFREZ.

%	Author(s): L. Shure, 5-17-88
%		   L. Shure, 12-17-90, revised
%	Copyright (c) 1984-94 by The MathWorks, Inc.
%	$Revision: 1.5 $  $Date: 1994/01/25 17:59:37 $

%	References:
%	  [1] T.W. Parks and C.S. Burrus, Digital Filter Design,
%	      John Wiley and Sons, 1987, p226.

K = length(h) - 1;
M = nb; N = na;
if K <= max(M,N)      % zero-pad input if necessary
    disp('Warning (in PRONY): model order too large for data; zeropadding data')
    K = max(M,N)+1;
    h(K+1) = 0;
end
c = h(1);
H = tril(toeplitz(h/c));	
% K+1 by N+1
if (K > N)
    H(:,(N+2):(K+1)) = [];
end
% Partition H matrix
H1 = H(1:(M+1),:);	% M+1 by N+1
h1 = H((M+2):(K+1),1);	% K-M by 1
H2 = H((M+2):(K+1),2:(N+1));	% K-M by N
a = [1; -H2\h1].';
b = c*a*H1.';

