periodogram for 200 Hz sample rate returns 129 array length
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
why periodogram for 200 Hz sample rate, for 1 second, returns an array lenght of 129, if called without parameters. why it's not 100
signal = linspace(0,3000,200)'; %this is 1 second of my signal (200 because that's the sample rate)
[x,y] = periodogram(signal,[],[],200);
x
0 Kommentare
Akzeptierte Antwort
Paul
am 24 Jan. 2023
Hi sam,
signal = linspace(0,3000,200)'; %this is 1 second of my signal (200 because that's the sample rate)
[x,y] = periodogram(signal,[],[],200);
numel(signal)
Because signal is only 200 elements and nfft is set for default, nfft will be (according to periodogram)
nfft = max(256,2^nextpow2(length(signal)))
The default for "freqrange" is 'onesided', in which case with nfft = 256, x will have length nfft/2 + 1 = 129 (also on periodogram)
3 Kommentare
Paul
am 24 Jan. 2023
Bearbeitet: Paul
am 24 Jan. 2023
I don't know what you mean by "100 Hz and not 129 bins," as in I don't know how you're relating Hz and bins. In the original code, the periodogram was computed as
signal = linspace(0,3000,200)'; %this is 1 second of my signal (200 because that's the sample rate)
[x,y] = periodogram(signal,[],[],200);
The resulting frequency vector y has
numel(y)
129 bins and the final frequency in y is
y(end)
100 Hz, which is what happens when nfft is even and freqrange is onesided. With nfft even, numel(y) will always be odd when freqrange is onesided.
In the new code
[x,y] = periodogram(signal,[],199,200);
the frequency vector has 100 bins
numel(y)
but the final frequency point is just short of 100 Hz
y(end)
which is what happens when nfft is odd and freqrange is onesided.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Spectral Measurements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!