I'm reading in a small wav-file and just extract the first 512
coefficients from that file. I then proceed to find the periodogram
PSD estimate of that 'frame'. In the following code 'x' is the vector
containing the 512 coefficients:
h = spectrum.periodogram('hann');
hopts = psdopts(h,x); % Default options based on the signal x
set(hopts,'NFFT',512,'Fs',Fs,'SpectrumType','onesided');
psd(h,x,hopts);
However when I view the properties of the object by:
objproperties = psd(h,x,hopts)
the length of the Data vector and (obviously) frequency vector is 257,
rather than the expected 256. I'm using MatLab 7.5.0.
Hope someone can clarify this for me. Thanks :)
Periodogram returning extra values
Started by ●October 29, 2008
Reply by ●October 30, 20082008-10-30
>I'm reading in a small wav-file and just extract the first 512 >coefficients from that file. I then proceed to find the periodogram >PSD estimate of that 'frame'. In the following code 'x' is the vector >containing the 512 coefficients: > >h = spectrum.periodogram('hann'); >hopts = psdopts(h,x); % Default options based on the signal x >set(hopts,'NFFT',512,'Fs',Fs,'SpectrumType','onesided'); >psd(h,x,hopts); > >However when I view the properties of the object by: > >objproperties = psd(h,x,hopts) > >the length of the Data vector and (obviously) frequency vector is 257, >rather than the expected 256. I'm using MatLab 7.5.0. >Hope someone can clarify this for me. Thanks :) >The length of 257 is correct-- An N point DFT of a real signal returns N/2 + 1 values. Here is a link on the topic. Regards, Steve http://www.dspguide.com/ch12/1.htm
Reply by ●October 30, 20082008-10-30
SteveSmith wrote: (snip)> The length of 257 is correct-- An N point DFT of a real > signal returns N/2 + 1 values. Here is a link on the topic.> http://www.dspguide.com/ch12/1.htmThis is going to get darn close to the topic of another thread related to Nyquist. Isn't that N/2+1st point the one at the Nyquist frequency? Now, to look at it another way without including the DFT, consider sampling a band limited and time limited signal. If the duration of the signal is N Fs, and the signal is not periodic, how many sample points do we need to be able to recreate the signal? IT seems to me that N+1 points are needed to properly include the end points. A signal that isn't time limited doesn't have end points. -- glen
Reply by ●October 30, 20082008-10-30
On Oct 30, 11:03 am, "SteveSmith" <Steve.Smi...@SpectrumSDI.com> wrote:> >I'm reading in a small wav-file and just extract the first 512 > >coefficients from that file. I then proceed to find the periodogram > >PSD estimate of that 'frame'. In the following code 'x' is the vector > >containing the 512 coefficients: > > >h = spectrum.periodogram('hann'); > >hopts = psdopts(h,x); % Default options based on the signal x > >set(hopts,'NFFT',512,'Fs',Fs,'SpectrumType','onesided'); > >psd(h,x,hopts); > > >However when I view the properties of the object by: > > >objproperties = psd(h,x,hopts) > > >the length of the Data vector and (obviously) frequency vector is 257, > >rather than the expected 256. I'm using MatLab 7.5.0. > >Hope someone can clarify this for me. Thanks :) > > The length of 257 is correct-- An N point DFT of a real signal returns N/2 > + 1 values. Here is a link on the topic. > Regards, > Steve > > http://www.dspguide.com/ch12/1.htmThe N point DFT of a real signal returns a real value at DC, N/2 - 1 complex values, and an imaginary value at fs/2; a total of N values from N real samples. Dale B. Dalrymple http//:dbdimages.com
Reply by ●October 30, 20082008-10-30
On Oct 30, 1:31 pm, Glen Herrmannsfeldt <g...@ugcs.caltech.edu> wrote:> (snip) > > > This is going to get darn close to the topic of another > thread related to Nyquist. Isn't that N/2+1st point the one > at the Nyquist frequency? > > Now, to look at it another way without including the DFT, > consider sampling a band limited and time limited signal. > > If the duration of the signal is N Fs, and the signal is > not periodic, how many sample points do we need to be able > to recreate the signal? IT seems to me that N+1 points > are needed to properly include the end points. A signal > that isn't time limited doesn't have end points. > > -- glenThe signal may be time limited. The DFT doesn't care. The DFT is a circular convolution. It has no end points. The N + 1 'points' don't represent the same number of values. Some are single values and some are complex with two values. Dale B. Dalrymple
Reply by ●October 30, 20082008-10-30
dbd wrote: (snip, I wrote)>>Now, to look at it another way without including the DFT, >>consider sampling a band limited and time limited signal.>>If the duration of the signal is N Fs, and the signal is >>not periodic, how many sample points do we need to be able >>to recreate the signal? IT seems to me that N+1 points >>are needed to properly include the end points. A signal >>that isn't time limited doesn't have end points.> The signal may be time limited. The DFT doesn't care. The DFT is a > circular convolution. It has no end points.> The N + 1 'points' don't represent the same number of values. Some are > single values and some are complex with two values.As I said, though, that paragraph was meant not to be related to the DFT, but to sampling and Nyquist. For a given length non-periodic signal how many sample points do you need to reconstruct a band limited signal? It seems to me that for a periodic signal it is N, and for a non-periodic signal it is N+1 because the ends could have different values. I was trying to connect the N+1 to the discussion on DFT, but not to the DFT itself. -- glen
Reply by ●October 30, 20082008-10-30
dbd wrote: (snip)> The N point DFT of a real signal returns a real value at DC, N/2 - 1 > complex values, and an imaginary value at fs/2; a total of N values > from N real samples.And by symmetry, the DFT of an imaginary signal should return an imaginary value at DC, N/2-1 complex values, and a real value at fs/2. I don't believe that there is a mathematical symbol for 'less than and partially equal to'. -- glen
Reply by ●October 30, 20082008-10-30
On Oct 30, 4:12 pm, Glen Herrmannsfeldt <g...@ugcs.caltech.edu> wrote:> ... > For a given length > non-periodic signal how many sample points do you need to > reconstruct a band limited signal? It seems to me that > for a periodic signal it is N, and for a non-periodic signal > it is N+1 because the ends could have different values. > ... > -- glenWhat non-periodic band limited signal can you reconstruct from N+1 sample points? Doesn't Nyquist deal with bandwidths and rates, not numbers of samples? Dale B. Dalrymple
Reply by ●October 31, 20082008-10-31
dbd wrote: (snip)> What non-periodic band limited signal can you > reconstruct from N+1 sample points?> Doesn't Nyquist deal with bandwidths and > rates, not numbers of samples?One that is N divided by the appropriate sampling rate long. -- glen
Reply by ●October 31, 20082008-10-31
On 31 Okt, 00:12, Glen Herrmannsfeldt <g...@ugcs.caltech.edu> wrote:>�For a given length > non-periodic signal how many sample points do you need to > reconstruct a band limited signal?The question is irrelevant. You don't reconstruct a signal form its PSD. The PSD lacks phase information.>�It seems to me that > for a periodic signal it is N, and for a non-periodic signal > it is N+1 because the ends could have different values.When you include the n=0 and n=N/2 coeffcients (N even) to form an N/2+1 PSD estimate from a real-valued signal, the reason is that there are N/2+1 distinct coeffcients in the PSD estimate. The n=0 and n = N/2 coefficients appear one time each, all the others appear twice. Returning the n = N/2 coefficient makes perfect sense since it is needed for a complete decription of the PSD (its relative magnitude might e.g. tell something about the quality of an anti- alias filter). And anyway, it is the analyst's responsibilty, not the implementer of the PSD estimator routine, to make the decision on whether to include the n = N/2 coeffcient in this or that analysis, depending on the context. Rune






