# How to reconstruct the signal which is subjected to FIR filtering - Matlab

I have a signal $x$ which is corrupted by Gaussian noise. The signal $x$ is convolved with a filter with coefficients $h = [1, -2, 1]$, to generate signal $y$. Now the signal is taken to Discrete Fourier Transform (DFT) domain by FFT.

In MATLAB,

y = conv(x,h);
z = fft(y);


How can I compensate for the modulation caused by $h$ in the DFT domain. I have attenuated the frequency components of $x$ by the filter $h$.

I know that to invert an FIR filtered signal, IIR filters are required. Can I do some compensation (multiplying coefficients of $z$) on Fourier domain.

You can if the filter does not introduce any zeros in the frequency domain, which your filter unfortunately does because its frequency response is zero for $\omega=0$. What you normally have to do is zero-pad the impulse response $h(n)$ to the same length as the result of the convolution, i.e. $y(n)$. Then you compute the DFT (FFT) of the two zero-padded sequences:

$$H(k)=DFT\{h(n)\}$$

$$Y(k)=DFT\{y(n)\}$$

Now you have

$$Y(k)=H(k)X(k)\tag{1}$$

where $X(k)$ is the DFT (FFT) of the zero-padded input signal (such that it has the same length as $y(n)$). From (1) you can compute $X(k)$ for all indices $k$ for which $H(k)\neq 0$. In your case $H(0)=0$, so you can't compute $X(0)$. You can, however, compute all other values of $X(k)$ from (1).

For your example this means that you can determine the original time signal $x(n)$ from $X(k)$ up to its mean value. E.g., if you choose $X(0)=0$ and apply an inverse DFT you'll get the original signal but with a mean value of zero.

In Matlab it would look like this:

Nx = 100; x = randn(Nx,1);    % some input signal
h = [1,-2,1]'; Nh = 3;        % impulse response
y = conv(x,h);                % convolution