0
$\begingroup$

I am trying to filter off two unwanted terms in this frequency spectrum (the spectrum on top). First, I used a convolution between a rectangular window to make the unwanted terms equal to zero.

enter image description here

the first problem is when I tried to centralize the remaining part and multiplying it by a cos ( 2 * pi * f *t) I didn't get any result.

And my second question about hamming window is that in an article about a similar issue, a hamming and a blackman window were used. So, is it possible to use hamming window to filter off the unwanted terms? if yes, then how do I choose the starting and the final point of the hamming window to leave only the desired part! I really need help to understand how does it work and how to use it.

$\endgroup$
  • $\begingroup$ Welcome to DSP.SE! Are you saying that the second graph is obtained by filtering the time domain signal (the spectrum of which is in the first graph) with a rectangular window? What do you mean by "didn't get any result" ? Was it all zero? Did it not change the signal? In general, windows are not used to filter signals. They multiply (modulate) signals to localize in time or to improve (smooth) the subsequent frequency domain plots. $\endgroup$ – Peter K. Sep 8 '15 at 13:18
  • $\begingroup$ The second graph is obtained by filtering the frequency domain of the signal ( the first graph) with a convolution with a vector of ones and zeros. What I really need is to leave only that part ( of the second graph) and centralize it. So I tried to use dirac delayed and exp( j* 2 *pi *f) the signal didn't change. So are you saying that I couldn't use hamming window to filter off the unwanted terms? So what are the others methods to eliminate such unwanted parts? $\endgroup$ – user3475463 Sep 8 '15 at 13:40
  • $\begingroup$ Are you sure it's a convolution? It looks like it's just a multiplication (in the frequency domain) to zero out the bits you don't need. $\endgroup$ – Peter K. Sep 8 '15 at 13:42
  • $\begingroup$ Yes true. it's a multiplication ( term by term)in the frequency domain. I guess I got confused. So is there another way to do it? $\endgroup$ – user3475463 Sep 8 '15 at 13:48
0
$\begingroup$

Below is some code (in scilab which is similar to but not the same as matlab) that attempts to do what you're saying.

The output is the following graph which has:

  • The original signal
  • The signal multiplied by the window to leave just the left-hand peak.
  • The signal modulated with a complex exponential to shift the remaining peak to the centre (DC).

enter image description here

// 25709
N = 1024;
dc = 1 + rand(1,N,'norm');
fc = 0.388729874;
a = 1+0.5*rand(1,N,'norm');
t = [0:N-1];
phi = 0.187238947;
x = dc + a.*sin(2*%pi*fc*t + phi);
X= fft(x);

f = fftshift((fftshift([0:N-1]) - N/2)/N);

clf;
subplot(311);
plot(f, fftshift(abs(X)))

subplot(312);
wind = [zeros(1,N-500) ones(1,500) ];
plot(f,fftshift(abs(X.*wind)));

subplot(313);
y = ifft(X.*wind);
yy = y.*exp(%i*2*%pi*fc*t);
plot(f,fftshift(abs(fft(yy))))
$\endgroup$
  • 1
    $\begingroup$ Thanks, it worked. So in order to compare filtering results can you tell me if there is another type of filter I could use? $\endgroup$ – user3475463 Sep 8 '15 at 21:26
  • $\begingroup$ The only issue with what you're doing is that zeroing out FFT bins arbitrarily can cause "time aliasing" in the result. Because FFT-based convolution is circular, not linear, you need to ensure that the FFT length is at least $N+M-1$ where $N$ is the signal length and $M$ is the length of your FIR filter. If you just zero out FFT coefficients, $N=M$ but you only have $N$ samples of the FFT (without zero padding). $\endgroup$ – Peter K. Sep 9 '15 at 0:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.