You are here : matlabSignal Processinglpc

lpc() - Signal Processing

lpc determines the coefficients of a forward
linear predictor by minimizing the prediction error in the least squares
sense. It has applications in filter design and speech coding.[a,g] = lpc(x,p) finds the coefficients of
a pth-order linear predictor (FIR filter) that
predicts the current value of the real-valued time series x based
on past samples.x^(n)=−a(2)x(n−1)−a(3)x(n−2)−⋯−a(p+1)x(n−p)p is the order of the prediction filter polynomial, a = [1 a(2) ... a(p+1)]. If p is unspecified, lpc uses
as a default p = length(x)-1.
If x is a matrix containing a separate signal in
each column, lpc returns a model estimate for each
column in the rows of matrix a and a column vector
of prediction error variances g. The length of p must
be less than or equal to the length of x.


Syntax

[a,g] = lpc(x,p)


Example

Estimate a Series Using a Forward PredictorOpen This Example
Estimate a data series using a third-order forward predictor. Compare the estimate to the original signal.
First, create the signal data as the output of an autoregressive process driven by normalized white Gaussian noise. Use the last 4096 samples of the AR process output to avoid startup transients.noise = randn(50000,1);
x = filter(1,[1 1/2 1/3 1/4],noise);
x = x(45904:50000);
Compute the predictor coefficients, estimated signal, prediction error, and autocorrelation sequence of the prediction error.a = lpc(x,3);
est_x = filter([0 -a(2:end)],1,x);
e = x-est_x;
[acs,lags] = xcorr(e,'coeff');
Compare the predicted signal to the original signal.plot(1:97,x(4001:4097),1:97,est_x(4001:4097),'--'), grid
title 'Original Signal vs. LPC Estimate'
xlabel 'Sample number', ylabel 'Amplitude'
legend('Original signal','LPC estimate')

Plot the autocorrelation of the prediction error.plot(lags,acs), grid
title 'Autocorrelation of the Prediction Error'
xlabel 'Lags', ylabel 'Normalized value'

The prediction error is approximately white Gaussian noise, as expected for a third-order AR input process.


Output / Return Value


Limitations


Alternatives / See Also


Reference