# MATLAB : How to filter a data signal

I have a data signal (column vector) with N values taken over at specific sample rate (dx) at a fixed frequency. After taking the Fourrier transform of this signal and representing it in the Fourier Domain (with fftshift), I need to eliminate the parts situated in the origin and in the positive side. The final signal I need is the one with the negative shift. Therefore, after filtering the unwanted parts I will need to perform an inverse Fourier transform to recover the signal in time domain and center it in the origin. Finally, I do not understand how to filter the spectrum when there is no frequency variation and when I’ve tried specifying a sample frequency and then applying a matlab filter I didn’t get any results. Can anyone help me to understand how to make this work please? PS: the spectrum is in the figure below • In Matlab there is also a toolbox called filter designer toolbox that will greatly assist you in filtering and showing you the produced filter. If you're new to it , use fir equiripple and specify a small order (suitable to your application) – Jack Dec 7 '17 at 21:18
• Are you taking into account that keeping just the negative side of the spectrum would mean that the filtered signal would not be real-valued anymore? – Tendero Dec 8 '17 at 0:08
• Could you share the signal samples with us? – Royi Jun 6 '18 at 11:02

## 2 Answers

This task its not so hard, you only should create a vector, using ones, of the same size and set to zero the positions that correspond with the frequencies that you don't want. Apply an element-element multiplication between the vector and your signal. Finally apply the inverse Fourier transform in the obtained vector. The response you will obtain will be a complex one, so you need to graphic only real or imaginary part if you want to appreciate it in a graphical way, you also can graphic the absolute of the signal in order to observe the magnitude of it.

This type of filter is known as ideal filter and is impossible to apply in real world. In Fourier domain, filter is just a multiplication while in space domain to filter is necessary to apply a convolution between the signal and a kernel.

• In addition to your answer, I found out the important effect which should be considered before zeroing the bins after FFT. This question Why is it a bad idea to filter by zeroing out FFT bins? has sufficient details regarding zeroing frequency bins after FFT for filtering purpose. – Zeeshan May 11 '17 at 11:06
• As @Zeeshan, the method proposed in this answer is probably not what the OP wants, as it may cause undesired effects. – Tendero Dec 8 '17 at 0:16

In general, removing the energy at DC and all the positive frequencies is equivalent to subtracting the mean and dividing by two. The FFT will always be two-sided and symmetrical.

• inverse Fourier transform will give real output for symmetric input, for one sided signals output will be complex and only real part of op is actual signal divided by two. – arpit jain Sep 13 '16 at 5:42