%Function CD1: Cepstral distance between two spectra using cepstral coefficients.
%              !!!    WITHOUT coefficient c[0]    !!!
%
%Usage: D=cd1(c1,c2,cp);
%  c1  - vector (matrix) of cepstral coefficients of the first spectrum (WITHOUT c[0])
%  c2  - vector (matrix) of cepstral coefficients of the second spectrum (WITHOUT c[0])
%     NOTE! If c1 and c2 are matrices, particular realizations of cepstra must be in rows!
%  cp  - number of cepstral coefficients               <minimum of size(c1,1),size(c2,1)>
 
%                 Made by Petr Pollak, 12.12.2021

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

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


c1=c1(:,1:cp);
c2=c2(:,1:cp);

D=4.3429*sqrt(2*sum((c1-c2).^2,2));
