%Function CD0: Cepstral distance between two spectra using cepstral coefficients.
%              !!!   WITH THE COEFFICIENT C[0]   !!!
%
%Usage: D=cd0(c1,c2,cp);
%  c1  - vector (matrix) of cepstral coefficients of the first spectrum (including c[0])
%  c2  - vector (matrix) of cepstral coefficients of the second spectrum (including c[0])
%  cp  - number of cepstral coefficients (without c[0])      <minimum of length(c1),length(c2)>-1

%                   Made by Petr Pollak,  12.12.2021

function D=cd0(c1,c2,cp);

if nargin<3,
  cp=min([length(c1) length(c2)])-1;
elseif  cp>=min([length(c1) length(c2)]),
  cp=min([length(c1) length(c2)])-1;
  disp('Warning cd0.m: Value of 3rd input is greater than a length of input cepstral vectors!') ;
  disp(['   New value has been set to min([length(c1) length(c2)], i.e. cp = ' num2str(cp)]) ;
end;


D=4.3429*sqrt ( (c1(1)-c2(1))^2 + 2*sum((c1(2:cp+1)-c2(2:cp+1)).^2));
