FFT function from raw sound pressure data

Hi,
I have some raw time vs sound pressure data that I would like to perform an FFT on and display as a frequency spectrum graph. I am struggling with how to get the correct frequency vector.
My data appears as: time = [0 1 2 3 4...] with corresponding sound pressure levels [5 34 23...]
Any help would be greatly appreciated.
Thanks for your time, Sam.

1 commentaire

compare the code below with this command :
>>figure, psd(p) % with p sound pressure

Connectez-vous pour commenter.

 Réponse acceptée

Youssef  Khmou
Youssef Khmou le 6 Mar 2013
hi Sam, try this code .
% Given you vector p and time .
Fs=1; % sampling frequency.
L=length(p);
N=ceil(log2(L));
fp=fft(p,2^N)/(L/2);
Power=fp.*conj(fp);
f=(Fs/2^N)*(0:2^(N-1)-1);
plot(f,Power(1:2^(N-1)),'r'), xlabel(' Frequency (Hz)'), ylabel(' Magnitude (w)'),
title(' Power Spectral Density'), grid on;

4 commentaires

Sam
Sam le 6 Mar 2013
Thanks a lot mate. Perfect.
Sam
Sam le 6 Mar 2013
Oh just one thing. What is the units of the y axis? Should the w be replaced by dB or some other unit?
in the first case the magnitude is simply in volts, or depends on what unis you are using , Pascal , Bar...but to plot in dB then :
semilogy(f,Power(1:2^(N-1)),'r'), xlabel(' Frequency (Hz)'), ylabel(' Magnitude (dB)'),
title(' Power Spectral Density, logarithmic scale '), grid on;
Sam
Sam le 6 Mar 2013
Great cheers.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Fourier Analysis and Filtering dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by