From: Jos on
I still got a question concerning the fft.

Is it correct if I apply the following lines?

--
nfft = 2^^nextpow2(length(H));
Pxx = abs(fft(H,nfft)).^2/length(H);
--

My concerns are mostly about the frequency outcome (x-axis), they do very a lot with the outcome of the earlier mentioned PSD.
From: Wayne King on
"Jos " <j.g.h.haarman(a)student.utwente.nl> wrote in message <i2mt0l$ahc$1(a)fred.mathworks.com>...
> I still got a question concerning the fft.
>
> Is it correct if I apply the following lines?
>
> --
> nfft = 2^^nextpow2(length(H));
> Pxx = abs(fft(H,nfft)).^2/length(H);
> --
>
> My concerns are mostly about the frequency outcome (x-axis), they do very a lot with the outcome of the earlier mentioned PSD.

Hi Jos, I think your zero-padding is fine, but I'm not sure with such a long data record that you really need to zero pad. Normally zero padding the DFT is done to either interpolate the frequency axis or to gain some computational speed advantage. As far as the former, your DFT bin spacing is Fs/N and since your N is so large and your sampling frequency so small, I don't see why you would need a larger N.

Your scaling on the PSD estimate is not quite right and you will accordingly notice some discrepancy between the output of MATLAB's psd() method and your approach using fft(). See the following thread for an explanation of the scaling:

http://www.mathworks.com/matlabcentral/newsreader/view_thread/285433#757466

Hope that helps,
Wayne
From: Jos on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <i2mu04$g3k$1(a)fred.mathworks.com>...
> "Jos " <j.g.h.haarman(a)student.utwente.nl> wrote in message <i2mt0l$ahc$1(a)fred.mathworks.com>...
> > I still got a question concerning the fft.
> >
> > Is it correct if I apply the following lines?
> >
> > --
> > nfft = 2^^nextpow2(length(H));
> > Pxx = abs(fft(H,nfft)).^2/length(H);
> > --
> >
> > My concerns are mostly about the frequency outcome (x-axis), they do very a lot with the outcome of the earlier mentioned PSD.
>
> Hi Jos, I think your zero-padding is fine, but I'm not sure with such a long data record that you really need to zero pad. Normally zero padding the DFT is done to either interpolate the frequency axis or to gain some computational speed advantage. As far as the former, your DFT bin spacing is Fs/N and since your N is so large and your sampling frequency so small, I don't see why you would need a larger N.
>
> Your scaling on the PSD estimate is not quite right and you will accordingly notice some discrepancy between the output of MATLAB's psd() method and your approach using fft(). See the following thread for an explanation of the scaling:
>
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/285433#757466
>
> Hope that helps,
> Wayne

The thread you're referring to is very helpful in this, thanks. (My understanding of spectral analysis does not go this far, so I can't comment on it now, I'll have a look in the library tomorrow. )

So if I understand the things correctly, it is possible to have frequency range of 0-~8200Hz for the FFT and a frequency range for the PSD of 0-1Hz.
From: Walter Roberson on
Jos wrote:
> I still got a question concerning the fft.
> Is it correct if I apply the following lines?

> nfft = 2^^nextpow2(length(H));
> Pxx = abs(fft(H,nfft)).^2/length(H);

Matlab does not have a ^^ operator.

The result of nextpow2 is already a power of 2. It is not clear why you
would want to take 2 to that value.
From: Jos on
Walter Roberson <roberson(a)hushmail.com> wrote in message <bxD3o.44134$f_3.42154(a)newsfe17.iad>...
> Jos wrote:
> > I still got a question concerning the fft.
> > Is it correct if I apply the following lines?
>
> > nfft = 2^^nextpow2(length(H));
> > Pxx = abs(fft(H,nfft)).^2/length(H);
>
> Matlab does not have a ^^ operator.
>
> The result of nextpow2 is already a power of 2. It is not clear why you
> would want to take 2 to that value.

Typo. Should be; nfft = 2^nextpow2(length(H)).

At this moment I cannot give you an answer to the question why I'm taking 2 to that value, I'll get back on you, but as far as I know, this is common.