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
divide it in bins of 10 Hz wide
calculate the average FT magnitude in each of these bins.
My questions are:
- Which FFT Magnitude spectrum should I use between the following graphs?
- How should proceed to divide my signal (99144 total samples with 44100 sample rate) in 10 Hz bins? Can I achieve this just by using Matlab's pwelch function?
-> Here the frequencies of the single-sided magnitude are 0 – 22000 Hz -> Which means I should have 2200 bins of 10 Hz -> Should I just create a new array and put the average mean of all values between 0 – 10 Hz, 10 – 20 Hz and so on?
[signal,fs]=audioread(filename); % fs = 44100 N = length(signal); % N = 94144 %% Single-sided magnitude spectrum with frequency axis in Hertz % Each bin frequency is separated by fs/N Hertz. X_mags = abs(fft(signal)); bin_vals = [0 : N-1]; fax_Hz = bin_vals*fs/N; % conversion Hz - Bins N_2 = ceil(N/2); figure; subplot(4,1,1); plot(fax_Hz(1:N_2), X_mags(1:N_2)) xlabel('Frequency (Hz)') ylabel('Magnitude'); title('Single-sided Magnitude spectrum (Hertz)'); axis tight %% Single-sided magnitiude spectrum in decibels and Hertz X_mags = abs(fft(signal)); bin_vals = [0 : N-1]; fax_Hz = bin_vals*fs/N; N_2 = ceil(N/2); subplot(4,1,2); plot(fax_Hz(1:N_2), 10*log10(X_mags(1:N_2))) xlabel('Frequency (Hz)') ylabel('Magnitude (dB)'); title('Single-sided Magnitude spectrum (Hertz)'); axis tight %% 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,3); 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,4); pwelch(signal,,,,fs); title(sprintf('Pwelch defaut values'));