Using FFT in matlab

822 Views Asked by At

I am not completely sure if this is where a MatLab question belongs, so if not, please direct me where I should ask.

But onto my question. I am working on trying to deconvolution a signal with noise. So I have $h(x)=f(x) \ast g(x) +n(x) $. I want to find what the function g is. n(x) is white gaussian noise. I am using the Wiener Deconvolution Method. The function I am using for h is a box:

x=-20:.01:20;
h=zeros(size(x));
h(1900:2100)=1; 

I know that the Fourier transform of the box should be a Sinc function, but when I use fft(h), I get nothing that resembles this. Additionally, this contains zeros, so when I use the linked method, I end up dividing by zero. So I am wondering how I can go about doing this correctly. (Note: I do not have the symbolic toolbox which was recommended me by a colleague).

1

There are 1 best solutions below

1
On BEST ANSWER

If you want to keep the length of $h$ unchanged (4001 samples) you can define it like

h=[ones(101,1);zeros(3800,1);ones(100,1)]

This will guarantee that its FFT is real-valued (up to numerical noise). The reason for this is that Matlab assumes that the first value of your signal, i.e. $h(1)$, corresponds to the actual index $0$ (i.e. the center of symmetry for a signal with a real-valued FFT). So if you want a signal which is symmetric, you need to shift the part corresponding to negative indices to the right (the 'end' of the signal). This is because the FFT implies a periodic continuation of the signal. Note that you still have to take the real part of the FFT of $h$ because due to small numerical errors, the imaginary part of the FFT of $h$ is in the order of $10^{-14}$, which corresponds to Matlab's floating point accuracy.