SYNTAX - obtain [pxx ,f] vectors from periodogram(_ fs); <— Errors in user's current usage

1 次查看(过去 30 天)
QUESTION: How do I correctly use [pxx, f] = periodogram(y_soundsource_data,window,nfft, Fs);
I need the pxx and f vectors to be able to index to find maxima.
For context ... trying to get the PSD local maxima, for 3 specific frequency ranges. I want both the x-frequency values and the PSD-y values.
I sent an email to someone, and he said to use the [pxx, f]= periodogram(_ Fs) version of the periodogram call.
Where pxx= the PSD y value vector and f= the x values which correspond to the frequency values that match 1:1 to the pxx points
Matlab Documentation Says:
matlabPeriodogram.JPG
Undesired Behavior:
  • When I do use [pxx, f] = periodogram(y_soundsource_data,window, nfft, Fs); a window maker pops up and it doesn't automatically plot or
calculate anything.
  • Tried function call--> [pxx, f]=periodogram([],Fs); which should give the PSD-estimate with default values, but then, it caused an error.
Code
%% audioread .wav file
[y Fs]= audioread('100-daddy1.wav');
%% y=source signal
sourceFig=figure(1);
plot(y);
xlabel('milliseconds'); ylabel('amplitude'); title('spectrogram = voice source signal');
%% PSD - Power Spectral Density <-- peaks here should give formants
filterfcn=figure(2);
PSD=periodogram(y); %calculate the power spectral density of the source signal
plot(PSD);
ylabel('magnitude || intensity of signal'); xlabel('frequency in Hz'); title('PSD of Source');
xlim([0, .35*10^4]);
%% PSD with modified window <--- window is the same length as x
PSD_mod_window= periodogram(y, window);
figure(4);
plot(PSD_mod_window); % don't understand why a window pops up or how to use it. Thought window, was supposed to be a vector of length x?
%% [pxx,f] = periodogram(_,fs)
%fs is the fourth input to periodogram
% to use default values, do [], for preceding args
[pxx4, f]= periodogram( [], Fs);
disp(sizeof(pxx4));
disp(sizeof(f));
How do I correctly use [pxx, f] = periodogram(y_soundsource_data,window,nfft, Fs); ?
I need the pxx and f vectors to be able to index to find maxima.

采纳的回答

ParkourPolkaDots
ParkourPolkaDots 2019-4-7
The reason window plotter came up, was because you used the window gate way function as an input argument to the call: [pxx, f] = periodogram(y_soundsource_data,window, nfft, Fs).
Deconstructing the [pxx, f]= periodogram(y_soundsource_data, window, nfft, Fs);
  1. You can get y_soundsource_data and Fs<-- sampling frequency, from the audioread function. file[y Fs]= audioread('100-daddy1.wav');
  2. window and nfft are not understood by the periodogram function UNLESS you define them.
  • y_soundsource_data and Fs are understood, because audioread returns the data metrics.
  • nfft - refers to the number of points used in the DFT. A larger nfft value will lead to a better estimation. nfft MUST be an integer. You can't have half a point.
  • window = vector of the size of the y_soundsource_data. 1:length_y_soundsource_data
  • both window and nfft need to be defined before you call the periodogram function.

更多回答(0 个)

类别

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

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by