function a=lpc(h,N);
%LPC	Linear Predictive Coefficients.
%	A = LPC(X,N) finds the coefficients of an Nth order auto-regressive
%	process that models the time series X as follows:
%	   X(n) = -A(2)*X(n-1) - A(3)*X(n-2) - ... - A(N+1)*X(n-N-1)
%	Here, X is the real input time series (a vector), and N is the order of 
%	denominator polynomial A(z), i.e. A = [ 1 A(2) ... A(N+1) ].
%
%	If you leave N unspecified, LPC uses a default N = LENGTH(X)-1.
%
%	LPC uses the autocorrelation method, also known as the maximum
%	entropy method (MEM) of spectral estimation. It calls the LEVINSON 
%	function.
%
%	See also PRONY, STMCB, LEVINSON.

%	R is the auto correlation vector, R(1) = E(h(t)h*(t)), 
%		R(2) = E(h(t+1)h*(t)),...
%	This method is sometimes called the MEM method of spectral estimation.

%	Author(s): T. Krauss, 9-21-93
%	Copyright (c) 1984-94 by The MathWorks, Inc.
%	$Revision: 1.5 $  $Date: 1994/01/25 17:59:28 $

    error(nargchk(1,2,nargin))
    if nargin<2, N = length(h)-1; end

    if (N>length(h)-1),
        % disp('Warning: zero-padding short input sequence')
        h(N+1)=0;
    end
    R = xcorr(h);
    M=length(h);
    R(1:M-1) = [];

    a = levinson(R,N);

