www.pudn.com > asr.rar > CEPCOEFF.M, change:2004-11-06,size:766b


function c=cepcoeff(sg,P,Q) 
 
%%  c = cepcoeff(sg,P,Q) 
%%   
%%  c -- LPC-derived cepstral coefficients 
%%  sg-- signal segment 
%%  P -- order of LPC model 
%%  Q -- number of coefficients 
%%  c includes 0-order coefficient c(1) 
 
%% LPC analysis 
a = lpc(sg,P); 
a=real(a); 
 
%% LPC-derived cepstral coefficients 
c=zeros(Q,1); 
c(1)=log(std(sg)^2); 
%c(1)=2*log(sum(sg)); 
c(1)=real(c(1)); 
c(2)=-a(2); 
 
for n=3:Q 
  temp_sum=0; 
  if (n=P+1) 
     for m=1:(n-1)-1 
      temp_sum=temp_sum+(1-m/(n-1))*a(m+1)*c(n-m); 
     end 
     c(n) = -a(n)-temp_sum; 
  else 
     for m=1:P 
      temp_sum=temp_sum+(1-m/(n-1))*a(m+1)*c(n-m); 
     end 
     c(n) = -temp_sum; 
  end 
end 
 
%% Cepstral Weighting 
w=1+(Q/2).*sin((pi/Q).*(1:Q)); 
c=c.*w'; 
 
return