Hamming window around a specific frequency
5 views (last 30 days)
Show older comments
Hello
So, I'm in need of a little help concerning the hamming windowing of a signal. In fact, I realised the windowing, but it's over the full length of the signal, which doesn't suit my needs.
Instead, I need the window to be specifically around a selected frequency, let's say 50 Hz for instance, to denoise my signal and accentuate the frequency in question. The problem is that I can't manage to specify the length of the window so that it's set around a desired frequency. Especially when I'm windowing the signal in time domain (so introducing a frequency is not so obvious) and realise the FFT of the convoluted signal afterwards.
Here's the code :
clear all ;
close all ;
clc ;
n1 = 1000;
Fe = 12000;
t = (0:n1-1)/Fe;
sig = sin(2*pi*50*t) ;
L = length (sig);
nfft = 2^nextpow2(L);
s_Hamming = s2.*hamming(L);
Sfft_Hamming = fft(s_Hamming,nfft)/L;
mYdft = (Sfft_Hamming);
mYdft = mYdft (1:nfft/2+1);
mYdft (2:end-1) = 2*mYdft(2:end-1);
f = Fe/2*linspace(0,1,nfft/2+1);
figure
plot(f,mYdft)
grid on
title('Spectre avec fenètre de Hamming ');
xlabel('Frequence');
ylabel('Amplitude');
Thank you for any kind of help.
0 Comments
Answers (1)
Star Strider
on 3 Mar 2016
MathWorks already did this for you!
See: Remove the 60 Hz Hum from a Signal. Just make the change from 60 Hz to 50 Hz and you have the filter you want.
0 Comments
See Also
Categories
Find more on Hamming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!