periodogram for 200 Hz sample rate returns 129 array length

1 view (last 30 days)
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
x = 129×1
1.0e+06 * 2.2500 1.1035 0.2091 0.0750 0.0438 0.0316 0.0222 0.0152 0.0112 0.0093

Accepted Answer

Paul
Paul on 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)
ans = 200
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)))
nfft = 256
The default for "freqrange" is 'onesided', in which case with nfft = 256, x will have length nfft/2 + 1 = 129 (also on periodogram)
  3 Comments
sam
sam on 25 Jan 2023
I beleive I need to do more reading on nfft, I wanted to end up with a frquency vector of 100 bins only not 129, that's why I thought using 199.
the part that confuses me is if changing the nfft might affect my periodogram results. I guess this is beyond the scope of this post and MATLAB itself.
thank you.
Sam

Sign in to comment.

More Answers (0)

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!