Discrete Cosine Transform
x = dct(a) x = dct(a, n)
Real or complex vector or real or complex matrix (2-dim dct).
Real or complex vector or real or complex matrix (2-dim dct).
Integer value for length of the input vector.
Discrete Cosine Transform (DCT) can linearly transform data into the frequency domain, where the data can be represented by a set of coefficients. The advantage of DCT is that the energy of the original data may be concentrated in only a few low frequency components of DCT depending on the correlation in the data. DCT express a signal (a set of numbers) in terms of a sum of cosine functions with different frequencies. For example, given a set A of n values, x = dct(a) returns the unitary discrete cosine transform of a. x = dct(a, n) pads or truncates a to length n before transforming.
The DCT is closely related to the Discrete Fourier Transform. You can often reconstruct a sequency very accurately from only a few DCT coefficients, a useful property for applications requiring data reduction. If you plan to use DCT for data compression, you should first find a good way to represent your data where the elements are correlated. For example, let us naively sort the elements of B and then apply DCT to the sorted set.