Accelerating the pace of engineering and science

• Trials

# cceps

Complex cepstral analysis

## Syntax

xhat = cceps(x)
[xhat,nd] = cceps(x)
[xhat,nd,xhat1] = cceps(x)
[...] = cceps(x,n)

## Description

Cepstral analysis is a nonlinear signal processing technique that is applied most commonly in speech processing and homomorphic filtering [1].

 Note   cceps only works on real data.

xhat = cceps(x) returns the complex cepstrum of the real data sequence x using the Fourier transform. The input is altered, by the application of a linear phase term, to have no phase discontinuity at ±π radians. That is, it is circularly shifted (after zero padding) by some samples, if necessary, to have zero phase at π radians.

[xhat,nd] = cceps(x) returns the number of samples nd of (circular) delay added to x prior to finding the complex cepstrum.

[xhat,nd,xhat1] = cceps(x) returns a second complex cepstrum xhat1 computed using an alternative factorization algorithm[1][2]. This method can be applied only to finite duration signals. See the Algorithm section below for a comparison of the Fourier and factorization methods of computing the complex cepstrum.

[...] = cceps(x,n) zero pads x to length n and returns the length n complex cepstrum of x.

## Examples

The following example uses cceps to show an echo.

```Fs = 100;
t = 0:1/Fs:1.27;

% 45Hz sine sampled at 100Hz
s1 = sin(2*pi*45*t);

% Add an echo with half the amplitude and 0.2 second later
s2 = s1 + 0.5*[zeros(1,20) s1(1:108)];

c = cceps(s2);
plot(t,c)
```

Notice the echo at 0.2 second.

expand all

### Algorithms

cceps is an implementation of algorithm 7.1 in [3]. A lengthy Fortran program reduces to these three lines of MATLAB® code, which compose the core of cceps:

```h = fft(x);
logh = log(abs(h)) + sqrt(-1)*rcunwrap(angle(h));
y = real(ifft(logh));
```
 Note   rcunwrap in the above code segment is a special version of unwrap that subtracts a straight line from the phase. rcunwrap is a local function within cceps and is not available for use from the MATLAB command line.

The following table lists the pros and cons of the Fourier and factorization algorithms.

AlgorithmProsCons
FourierCan be used for any signal.Requires phase unwrapping. Output is aliased.
FactorizationDoes not require phase unwrapping. No aliasingCan be used only for short duration signals. Input signal must have an all-zero Z-transform with no zeros on the unit circle.

In general, you cannot use the results of these two algorithms to verify each other. You can use them to verify each other only when the first element of the input data is positive, the Z-transform of the data sequence has only zeros, all of these zeros are inside the unit circle, and the input data sequence is long (or padded with zeros).

## References

[1] Oppenheim, A.V., and R.W. Schafer. Discrete-Time Signal Processing. Upper Saddle River, NJ: Prentice-Hall, 1999, pp. 788-789.

[2] Steiglitz, K., and B. Dickinson. "Computation of the complex cepstrum by factorization of the Z-transform" in Proc. Int. Conf. ASSP. 1977, pp. 723–726.

[3] IEEE® Programs for Digital Signal Processing. IEEE Press. New York: John Wiley & Sons, 1979.