function tc=centretime(x,fs,zk)

if zk==1,
    zaj=x(round(.9*length(x)):end).^2;
    RMS_zaj = sum(zaj)/length(zaj);
    energia=x.^2-RMS_zaj;
else
    energia=x.^2;
end;

% Centre Time
x=(0:length(energia)-1)/fs;
tc = sum(energia(:).*x(:))/sum(energia);