matlab lpc函数 c语言,lpc中matlab解自相关函数

function [aCoeff, tcount_of_aCoeff, e] = func_lev_durb (y, M);%莱文逊-杜宾递推算法

%M=how much, how much order?

if (nargin<2), M = 10; end   %prediction order=10;

sk=0;       %initializing summartion term "sk"

a=[zeros(M+1);zeros(M+1)]; %defining a matrix of zeros for "a" for init.

%MAIN BODY OF THIS PROGRAM STARTS FROM HERE>>>>>>>>>>>>>>

z=xcorr(y);

%finding array of R[l]

R=z( ( (length(z)+1) ./2 ) : length(z)); %R=array of "R[l]", where l=0,1,2,

%...(b+N)-1

%R(1)=R[lag=0], R(2)=R[lag=1],

%R(3)=R[lag=2]... etc

%GETTING OTHER PARAMETERS OF PREDICTOR OF ORDER "0":

s=1;        %s=step no.

J(1)=R(1);          %J=array of "Jl", where l=0,1,2...(b+N)-1

%J(1)=J0, J(2)=J1, J(3)=J2 etc

%GETTING OTHER PARAMETERS OF PREDICTOR OF ORDER "(s-1)":

for s=2:M+1,

sk=0;               %clearing "sk" for each iteration

for i=2:(s-1),

sk=sk + a(i,(s-1)).*R(s-i+1);

end                 %now we know value of "sk", the summation term

%of formula of calculating "k(l)"

k(s)=(R(s) + sk)./J(s-1);

J(s)=J(s-1).*(1-(k(s)).^2);

a(s,s)= -k(s);

a(1,s)=1;

for i=2:(s-1),

a(i,s)=a(i,(s-1)) - k(s).*a((s-i+1),(s-1));

end

end

%increment "b" and do same for next frame until end of frame when

%combining this code with other parts of LPC algo

%PREDICTION ERROR; FOR TESTING THE ABOVE PREDICTOR

aCoeff=a((1:s),s)';       %array of "a(i,s)", where, s=M+1

tcount_of_aCoeff = length(aCoeff);

est_y = filter([0 -aCoeff(2:end)],1,y);    % = s^(n) with a cap on page 92 of the book

e = y - est_y;

%plot(e); %supposed to be a white noise

%这是莱文逊-杜宾递推算法

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值