Asked by john karli
on 22 Dec 2018

I have given this code but i'm not really understand each line of code. .

function [ar,xi,e,m] = lpcauto(x,M,win,Olap)

% lpcauto --> Linear Predictor Coefficients.

% Check the required input arguments.

if (nargin < 4)

error('Not enough input arguments.')

end

% Number of data points.

Nx = length(x);

% Frame length is given by the window length.

N = length(win);

if (N == 1)

N = win; % If win is a scalar, then use

win = ones(N,1); % a rectangular window of this length.

end

if (Nx < N)

error('The window length cannot be larger than the signal length.')

elseif (N <= Olap)

error('The overlap must be smaller than the window length.')

end

% Number of frames.

F = fix((Nx-Olap)/(N-Olap));

% Initialize output arguments.

ar = zeros(M+1,F);

xi = zeros(M+1,F);

e = zeros(Nx,1);

m = zeros(F,1);

% Time index vectors.

n = 1:N; % Index of current speech frame.

n1 = 1:Olap; % Overlap in start of frame.

n2 = N-Olap+1:N; % Overlap in end of frame.

n3 = Olap+1:N; % From overlap in start to end of frame.

% Overlap-add weights in start and end of frame, respectively.

win1 = win(n1)./(win(n1)+win(n2)+eps);

win2 = win(n2)./(win(n1)+win(n2)+eps);

for (f=1:F)

% Short-term autocorrelation.

[r,eta] = xcorr(x(n).*win,M,'biased');

% LP analysis based on Levinson-Durbin recursion.

[a,xi(:,f),kappa] = durbin(r(M+1:2*M+1),M);

ar(:,f) = [1; -a];

% Prediction error signal obtained by inverse filtering.

ehat = filter(ar(:,f),1,x(n));

e(n) = [e(n(n1)).*win2 + ehat(n1).*win1; ehat(n3)]; % Overlap-add.

m(f) = n(N); % Time index of last point in frame.

n = n + (N-Olap); % Shift time index to next speech frame.

end

%-----------------------------------------------------------------------

% End of function lpcauto

Opportunities for recent engineering grads.

Apply Today
## 5 Comments

## KALYAN ACHARJYA (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/436921-how-to-understand-linear-prediction-coefficient-code#comment_653489

## john karli (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/436921-how-to-understand-linear-prediction-coefficient-code#comment_653494

## Image Analyst (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/436921-how-to-understand-linear-prediction-coefficient-code#comment_653497

## john karli (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/436921-how-to-understand-linear-prediction-coefficient-code#comment_653500

## John D'Errico (view profile)

Direct link to this comment:https://kr.mathworks.com/matlabcentral/answers/436921-how-to-understand-linear-prediction-coefficient-code#comment_653503

Sign in to comment.