# Compressing a time-domain signal in the frequency domain Matlab

I'm new to frequency domain analysis. Let's say I have a frequency domain representation from a time domain signal. What I want to do is taking frequencies with a low amplitude out of this frequency domain representation and then convert this frequency domain representation back to the time domain such that the result is almost the original time domain representation.

In Matlab what I want to do is something like this:

timeDomain(1:50) -> apply fft(timeDomain) -> inspect frequency domain and filter out low amplitude frequencies yielding a frequency domain vector x with length(x) probably (way) smaller than 50. (so x should contain only the frequencies with the highest amplitudes of the signal) -> apply ifft on this filtered complex vector -> Get an approximation of the original time domain signal (timeDomain(1:50) that has also length 50.

So my aim is to represent the time domain signal timeDomain(1:50) with less dimensions in the frequency domain without too much information about the signal getting lost, thus being able to reconstruct the time domain signal, so basically compression.

• Can you clarify what is your question? – MBaz May 5 '16 at 14:26
• I want to filter out non important frequency components of a signal. After that I want to convert to the time domain again. (I have just no idea how to do that last part in matlab) – Robert Dijkstra May 5 '16 at 14:30
• apply DCT instead of DFT (fft) and you will be happy. – Fat32 May 6 '16 at 0:23

Everything depends on what you call compressing. What you are proposing is Fourier or spectrum thresholding. You will generate a $50$-length vector with some zeroes, hopefully. Let us ignore "complexness" that requires two floats for now, you can deal with it using Hermitian symmetry.

Your main problem is actual compression. Forget about quantization first. The main issue is index location. Assume I have a transformed domain vector $T=[5, 1, 3 ,4, 0.5]$. Suppose I use a threshold on $2$. Now I give you the compressed version $T_c=[5, 3 ,4]$, a ratio of $3/5$.

Can you retrieve $T_d=[5, 0, 3 ,4, 0]$? Probably not, you do not know where the zeroes were. This problem somehow prevented matching pursuit to be used for image compression, because coding the index penalized the final compressed file too much.

You can look into Compressive Sampling. Exploiting the fact that the Frequency domain representation of your signal is sparse in nature, you can compress the time domain signal by applying a combination of a random matrix and a DFT matrix.

Lets say your time domain signal is $\boldsymbol{x}_{N \times 1}$. You can do the following:

$$\boldsymbol{y}_{M \times 1} = \boldsymbol{\Phi}_{M \times N}~ \boldsymbol{F}_{N \times N}~ \boldsymbol{x}_{N \times 1}$$

where, $M = O(k \log{(N/k)})$ with $k$ being the sparsity. $\boldsymbol{F}$ is a DFT matrix and $\boldsymbol{\Phi}$ is a random matrix (gaussian, bernoulli, etc.).

You can do the following to reconstruct your signal $\boldsymbol{\hat{x}}$ with almost no loss:

$$\min{\|\hat{\boldsymbol{x}}\|_{1}}~~\text{subject to} \| \boldsymbol{\Psi} \boldsymbol{\hat{x}} - \boldsymbol{y} \|_{2} \leq \epsilon$$

where, $\boldsymbol{\Psi} = \boldsymbol{\Phi}\boldsymbol{F}$

There are lots of existing methods to do this optimization for you. You can visit the huge Compressive Sampling Resources