I am analyzing sounds of daily activities recorded by a smartphone. For example walking, getting up from bed, falling, running etc.. (one at the time). Let’s take one them. My goal is to
- convert from time domain to frequency domain and then
- divide it in bins of 10 Hz wide
- calculate the average FT magnitude in each of these bins.
Questions:
When I use
fft
Matlab function, Do I have to chooseNFFT>N
and power of 2 (Y = fft(signal,NFFT)/N;
), or can I just use Y = fft(signal); ?In my case, is
signal = detrend(signal);
necessary before doing FFT?In order to have 10 Hz wide bins, using 4096 Hamming Window is the way to do so?
Do my plots need further processing in order to achieve my goal?
[signal,fs]=audioread(filename); % fs = 44100
N = length(signal); % N = 94144
%% Amplitude Spectrum
Y = fft(signal);
Y_mag = abs(Y);
Fbins = ((0: 1/N: 1-1/N)*fs).';
figure;
subplot(4,1,1);
plot(Fbins,Y_mag);
title('FFT MAGNITUTUDE REPONSE');
xlabel('FREQUENCY (HERTZ)');
ylabel('MAGNITUTDE');
%% Single-Sided Amplitude Spectrum
NFFT = 2^nextpow2(N);
Y_NFFT = fft(signal,NFFT)/N;
f_NFFT = fs/2*linspace(0,1,NFFT/2+1);
subplot(4,1,2);
plot(f_NFFT,2*abs(Y_NFFT(1:NFFT/2+1)))
title('Single-Sided Amplitude Spectrum of y(t)')
xlabel('Frequency (Hz)')
ylabel('|Y(f)|')
%% Pwelch defaut values
subplot(4,1,3);
pwelch(signal,[],[],[],fs);
title(sprintf('Pwelch defaut values'));
%% Pwelch Hamming Window 4096
len = 4096; % different sizes of Hamming Window
subplot(4,1,4);
pwelch(signal,len,[],len,fs);
title(sprintf('Pwelch Hamming Window Size :: %d',len));
Thank you very much