From: EUIX Wang on 11 Mar 2010 15:47 When using the periodogram function matlab states in its help file that "periodogram uses an nfft-point FFT of the windowed data (x.*window) to compute the periodogram. If the value you specify for nfft is less than the length of x, then x.*window is wrapped modulo nfft. If the value you specify for nfft is greater than the length of x, then x.*window is zero-padded to compute the FFT." Now what exactly does the first part mean? I understand how zero padding works what is wrapped modulo? Also does this work if your value of nfft is not a integer multiple of your number of data points? For example if I have 1000 data points and I pick nfft=210. Then does matlab zero pad the data with 50 extra zeros when executing periodogram?
From: Wayne King on 11 Mar 2010 17:02 "EUIX Wang" <kuhanw(a)gmail.com> wrote in message <hnbksd$jcv$1(a)fred.mathworks.com>... > When using the periodogram function matlab states in its help file that > > "periodogram uses an nfft-point FFT of the windowed data (x.*window) to compute the periodogram. If the value you specify for nfft is less than the length of x, then x.*window is wrapped modulo nfft. If the value you specify for nfft is greater than the length of x, then x.*window is zero-padded to compute the FFT." > > Now what exactly does the first part mean? I understand how zero padding works what is wrapped modulo? > > Also does this work if your value of nfft is not a integer multiple of your number of data points? For example if I have 1000 data points and I pick nfft=210. Then does matlab zero pad the data with 50 extra zeros when executing periodogram? Hi, what it means is that it divides the data into nonoverlapping segments of length NFFT, possibly padding the last one with zeros if a case like you describe holds. Then it stacks those segments and adds them together to form a length NFFT segment. So for example: X=1:20; NFFT=10; Y = buffer(X,NFFT); Y=sum(Y,2); Hope that helps, Wayne
From: TideMan on 11 Mar 2010 17:36 On Mar 12, 11:02 am, "Wayne King" <wmkin...(a)gmail.com> wrote: > "EUIX Wang" <kuh...(a)gmail.com> wrote in message <hnbksd$jc...(a)fred.mathworks.com>... > > When using the periodogram function matlab states in its help file that > > > "periodogram uses an nfft-point FFT of the windowed data (x.*window) to compute the periodogram. If the value you specify for nfft is less than the length of x, then x.*window is wrapped modulo nfft. If the value you specify for nfft is greater than the length of x, then x.*window is zero-padded to compute the FFT." > > > Now what exactly does the first part mean? I understand how zero padding works what is wrapped modulo? > > > Also does this work if your value of nfft is not a integer multiple of your number of data points? For example if I have 1000 data points and I pick nfft=210. Then does matlab zero pad the data with 50 extra zeros when executing periodogram? > > Hi, what it means is that it divides the data into nonoverlapping segments of length NFFT, possibly padding the last one with zeros if a case like you describe holds. Then it stacks those segments and adds them together to form a length NFFT segment. So for example: > > X=1:20; > NFFT=10; > Y = buffer(X,NFFT); > Y=sum(Y,2); > > Hope that helps, > Wayne Wayne Are you sure about this? I thought it transferred all the segments to the freq domain (using FFT), squared (to get PSD), then took the mean. If you do this in the time domain, as you suggest, you could conceivably cancel the signal before it gets transformed.
From: Wayne King on 11 Mar 2010 19:55 TideMan <mulgor(a)gmail.com> wrote in message <3a040376-fd14-418e-9574-31ae51d0a1a5(a)q2g2000pre.googlegroups.com>... > On Mar 12, 11:02 am, "Wayne King" <wmkin...(a)gmail.com> wrote: > > "EUIX Wang" <kuh...(a)gmail.com> wrote in message <hnbksd$jc...(a)fred.mathworks.com>... > > > When using the periodogram function matlab states in its help file that > > > > > "periodogram uses an nfft-point FFT of the windowed data (x.*window) to compute the periodogram. If the value you specify for nfft is less than the length of x, then x.*window is wrapped modulo nfft. If the value you specify for nfft is greater than the length of x, then x.*window is zero-padded to compute the FFT." > > > > > Now what exactly does the first part mean? I understand how zero padding works what is wrapped modulo? > > > > > Also does this work if your value of nfft is not a integer multiple of your number of data points? For example if I have 1000 data points and I pick nfft=210. Then does matlab zero pad the data with 50 extra zeros when executing periodogram? > > > > Hi, what it means is that it divides the data into nonoverlapping segments of length NFFT, possibly padding the last one with zeros if a case like you describe holds. Then it stacks those segments and adds them together to form a length NFFT segment. So for example: > > > > X=1:20; > > NFFT=10; > > Y = buffer(X,NFFT); > > Y=sum(Y,2); > > > > Hope that helps, > > Wayne > > Wayne > > Are you sure about this? > I thought it transferred all the segments to the freq domain (using > FFT), squared (to get PSD), then took the mean. > If you do this in the time domain, as you suggest, you could > conceivably cancel the signal before it gets transformed. Hi Tideman, I'm pretty sure it does it that way, but you're definitely making me think, which is always good :) Anyway, here's what I think it's doing with an example reset(RandStream.getDefaultStream); x = randn(10,1); nfft = 5; win = hamming(10); y = x.*win; %Periodogram with nfft less than segment length [Pxx,Fxx] = periodogram(x,hamming(10),nfft); % Pxx is 0.0024 0.4686 0.4955 % now the brute force way % wrapping the windowed time data with datawrap() % same as sum(buffer(y,5),2) Y = datawrap(y,nfft); ydft = fft(Y,5); % Window normalization U = win'*win; ydft = (1/(2*pi))*ydft.*conj(ydft)/U; % select the bins for one-sided estimate ydft = ydft(1:(nfft+1)/2); % scale for one-sided estimate 2*everything but DC ydft(2:end) = 2*ydft(2:end); Wayne
From: TideMan on 11 Mar 2010 23:01
On Mar 12, 1:55 pm, "Wayne King" <wmkin...(a)gmail.com> wrote: > TideMan <mul...(a)gmail.com> wrote in message <3a040376-fd14-418e-9574-31ae51d0a...(a)q2g2000pre.googlegroups.com>... > > On Mar 12, 11:02 am, "Wayne King" <wmkin...(a)gmail.com> wrote: > > > "EUIX Wang" <kuh...(a)gmail.com> wrote in message <hnbksd$jc...(a)fred.mathworks.com>... > > > > When using the periodogram function matlab states in its help file that > > > > > "periodogram uses an nfft-point FFT of the windowed data (x.*window) to compute the periodogram. If the value you specify for nfft is less than the length of x, then x.*window is wrapped modulo nfft. If the value you specify for nfft is greater than the length of x, then x.*window is zero-padded to compute the FFT." > > > > > Now what exactly does the first part mean? I understand how zero padding works what is wrapped modulo? > > > > > Also does this work if your value of nfft is not a integer multiple of your number of data points? For example if I have 1000 data points and I pick nfft=210. Then does matlab zero pad the data with 50 extra zeros when executing periodogram? > > > > Hi, what it means is that it divides the data into nonoverlapping segments of length NFFT, possibly padding the last one with zeros if a case like you describe holds. Then it stacks those segments and adds them together to form a length NFFT segment. So for example: > > > > X=1:20; > > > NFFT=10; > > > Y = buffer(X,NFFT); > > > Y=sum(Y,2); > > > > Hope that helps, > > > Wayne > > > Wayne > > > Are you sure about this? > > I thought it transferred all the segments to the freq domain (using > > FFT), squared (to get PSD), then took the mean. > > If you do this in the time domain, as you suggest, you could > > conceivably cancel the signal before it gets transformed. > > Hi Tideman, I'm pretty sure it does it that way, but you're definitely making me think, which is always good :) Anyway, here's what I think it's doing with an example > > reset(RandStream.getDefaultStream); > x = randn(10,1); > nfft = 5; > win = hamming(10); > y = x.*win; > %Periodogram with nfft less than segment length > [Pxx,Fxx] = periodogram(x,hamming(10),nfft); > % Pxx is 0.0024 0.4686 0.4955 > % now the brute force way > % wrapping the windowed time data with datawrap() > % same as sum(buffer(y,5),2) > Y = datawrap(y,nfft); > ydft = fft(Y,5); > % Window normalization > U = win'*win; > ydft = (1/(2*pi))*ydft.*conj(ydft)/U; > % select the bins for one-sided estimate > ydft = ydft(1:(nfft+1)/2); > % scale for one-sided estimate 2*everything but DC > ydft(2:end) = 2*ydft(2:end); > > Wayne Yes, this is what my personal fspect function does as well. Except that I cheat when it comes to scaling and simply set the area under the spectrum to the variance. |