how to use periodogram?

8 次查看(过去 30 天)
nah
nah 2012-10-2
i want to analyse a .wav file using spectral.periodogram, but i have a trouble, what should i do?
x = wavread('balaclava5s.wav'); size(x); N = 350208; Fs = 44100; ts = 1/fs; tmax = (N-1)*ts; t = 0:ts:tmax; periodogram(x)
is it right? i'm new to digital signal processing, and i have no basic.

采纳的回答

Wayne King
Wayne King 2012-10-2
编辑:Wayne King 2012-10-2
wavread() will return the sampling frequency. Then you input the sampling frequency into periodogram() (along with the other documented inputs) to get a meaningful frequency vector as an output.
[x,Fs] = wavread('balaclava5s.wav');
[Pxx,Freq] = periodogram(x,rectwin(length(x)),length(x),Fs);
plot(Freq,10*log10(Pxx))
grid on;
xlabel('Hz'); ylabel('dB/Hz');
Just
periodogram(x,rectwin(length(x)),length(x),Fs);
produces a plot without outputting any data.

更多回答(1 个)

nah
nah 2012-10-2
thankyou for your help, but i got these errors:
??? Error using ==> times Matrix dimensions must agree.
Error in ==> computeperiodogram at 55 xw = x.*win;
Error in ==> periodogram at 116 [Sxx,w] = computeperiodogram(x,win,nfft,esttype,Fs);
Error in ==> Coba at 2 [Pxx,Freq] = periodogram(x,rectwin(length(x)),length(x),Fs);
i don't know what those mean or how to fix it
  2 个评论
Wayne King
Wayne King 2012-10-2
编辑:Wayne King 2012-10-2
You likely have a two-channel recording from the .wav file.
Try this
[x,Fs] = wavread('balaclava5s.wav');
x = x(:,1);
[Pxx,Freq] = periodogram(x,rectwin(length(x)),length(x),Fs);
plot(Freq,10*log10(Pxx))
grid on;
xlabel('Hz'); ylabel('dB/Hz');
Then the rest of my example.
nah
nah 2012-10-3
oh my dear, it works!!! thank you so much for your help, thank you. may i ask something? what are those 2nd, 3rd, and 4th line for??

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by