- Study about Linear prediction.
- Undestand the basics of Matlab
- Corelate your undestanding line by line
- Undestand the each line (Syantax and logic)-Comment are already there
- Try to implement the complete code (Learn by doing)
- Still unable to get the answer-repeat step 1

# how to understand Linear prediction coefficient code.

2 views (last 30 days)

Show older comments

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

##### 5 Comments

John D'Errico
on 22 Dec 2018

Edited: John D'Errico
on 22 Dec 2018

### Answers (0)

### See Also

### Categories

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!