lpc.m
上传用户:doudz874
上传日期:2007-03-30
资源大小:792k
文件大小:1k
- function [A,C,F]=lpc(s);
- P=12;
- N=160;
- L=16;
- sw=s.*hamming(N);
- %A
- for i=1:P+1
- R(i)=0;
- for n=1:N-i
- R(i)=R(i)+sw(n+i-1)*sw(n);
- end;
- end;
- k(1)=-R(2)/R(1);
- flag=1;
- a(flag,1)=k(1);
- sigma(1)=(1-k(1)^2)*R(1);
- for m=2:P
- k(m)=-R(m+1);
- for i=1:m-1
- k(m)=k(m)-a(flag,i)*R(abs(i-m)+1);
- end;
- k(m)=k(m)/sigma(m-1);
- flag=~(flag-1)+1;
- a(flag,m)=k(m);
- for i=1:m-1
- a(flag,i)=a(~(flag-1)+1,i)+k(m)*a(~(flag-1)+1,m-i);
- end;
- sigma(m)=(1-k(m)^2)*sigma(m-1);
- end;
- A=a(flag,:);
-
- %C
- %ha(1)=0;
- %ha(2)=A(1);
- %for n=3:P+1
- % ha(n)=A(n-1);
- % for i=1:n-2
- % ha(n)=ha(n)-i/(n-1)*ha(i+1)*a(n-i);
- % end;
- %end;
- C(1)=-A(1);
- for n=2:P
- C(n)=-A(n);
- for m=1:n-1
- C(n)=C(n)-(1-m/n)*A(m)*C(n-m);
- end;
- end;
- for n=P+1:L
- C(n)=0;
- for m=1:P
- C(n)=C(n)-(1-m/n)*A(m)*C(n-m);
- end;
- end;
-
- spec=fft(sw,512);
- scep=log(abs(spec));
- E=ifft(scep,512);
- F=real(E(1:16)');
-
-
- %for i=1:L
- % C(i)=ha(i+1);%%%%%%%%
- %end;
-
-
-
-