Related Examples

Discrete Cosine Transform

The discrete cosine transform (DCT) is closely related to the
discrete Fourier transform. You can often reconstruct a sequence very
accurately from only a few DCT coefficients, a useful property for
applications requiring data reduction.

The DCT is defined by

y(k)=w(k)∑n=1Nx(n)cos(π2N(2n−1)(k−1)),k=1,2,…,N,

where

w(k)={1N,k=1,2N,2≤k≤N,

and N is the length of x.
The series is indexed from n = 1 and k = 1 instead of the
usual n = 0 and k = 0 because MATLAB® vectors
run from 1 to N instead of from 0 to N – 1.