how to implement hanning window with 50% overlap

15 vues (au cours des 30 derniers jours)
Wil
Wil le 18 Sep 2014
Modifié(e) : Walter Roberson le 1 Nov 2025 à 3:14
Hi there, I have a .wav file whic is attached here. I wish to get the sound pressure level (dB SPL re:1uPa) from this file and plot it against it's frequency components. Can someone check if my code is correct or what I need to do if it isn't. And very importantly, I need to apply a 'hanning window' with 50% overlap to my data, how do I do that?. Thanks very much for the anticipated helpful reply. Below is my code. Cheers.
% This reads in the .wav file
[data Fs] = wavread('C:wil.wav');
T = 1/Fs; % Sample time
L = length(data(:,1)); % Length of signal
t = (0:L-1)*T; % Time vector
x = data(:,1);
subplot(3,1,1), plot(t,x)
title('Signal')
xlabel('time (Seconds)')
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
Y = fft(x,NFFT)/L;
f = Fs/2*linspace(0,1,NFFT/2+1);
% Plot single-sided amplitude spectrum.
subplot(3,1,2), plot(f,2*abs((Y(1:NFFT/2+1))))
title('Magnitude of FFT')
xlabel('Frequency (Hz)')
ylabel('Amplitude')
xlim([0 10000]);
% Plot FFT in dB
subplot(3,1,3), plot(f,-10*(log10(abs((Y(1:NFFT/2+1)).^2))))
title('FFT in dB')
xlabel('Frequency (Hz)')
ylabel('Amplitude (dB)')
xlim([0 1000]);

Réponses (2)

José-Luis
José-Luis le 18 Sep 2014
Please make it easier for to help you and format your post.
Also, we don't have your sound file so we can't really run your code.
If you have the signal processing toolbox, Matlab has its implementation of the Hanning window called hann()
  1 commentaire
Wil
Wil le 18 Sep 2014
Thanks, I have attached one of the sound files

Connectez-vous pour commenter.


Ryan
Ryan le 1 Nov 2025 à 1:22
So im applying a Hann window to a 2d range image of .las point cloud. Current window overlapping is 50% could this result in smearing the range image? see 3d point cloud and resulting range image, my only other thought is that my projection may still be incorrect.

Community Treasure Hunt

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

Start Hunting!

Translated by