Filter löschen
Filter löschen

FFT Spectrum or Welch Spectrum

3 Ansichten (letzte 30 Tage)
Peter
Peter am 17 Okt. 2011
Hello everybody, I wrote a windowing function with an average of FFt's and calculated the same with the Matlab function pwelch. The welch algorithm and the FFT spectra resulting in a marked different spectral plot. I could narrow down the problem: The single spectra calculated with the fft are the same for both versions, but then the welch algorithm (Line 132: [Pxx,w,units] = computepsd(Sxx,w,options.range,options.nfft,options.Fs,esttype);) calculates the power densitiy, which results in a different spectral appearance. Along with this spectral shift, I get also a small shift in the highest frequency peak (from 30.0 Hz to 29.5 Hz; both calucated with a resolution of 0.1 Hz). Any common eplanation for that? Due to the fact, that I'm looking for the main period of oscillation in my data, I'm puzzled which on will be the right one? I'm gratefull for any hlep. Thanks a lot!

Akzeptierte Antwort

Wayne King
Wayne King am 17 Okt. 2011
Hi, Are you attempting to say that you wrote your own Welch overlapped segment averaging routine? The WOSA estimator is an estimate of the power spectral density.
The Welch estimate does result in a broadening of the peaks, which may explain the slight frequency shift you see. If you are attempting to identify a particular frequency then the periodogram has the best frequency resolution of any nonparametric estimator.
For example:
Fs = 1e3;
t = 0:1/Fs:1-1/Fs;
x = cos(2*pi*100*t)+randn(size(t));
psdPer = psd(spectrum.periodogram,x,'Fs',Fs,'NFFT',length(x));
% Welch estimate
hwelch = spectrum.welch;
% 5-Hz DFT bin spacing
hwelch.SegmentLength = 200;
psdWOSA = psd(hwelch,x,'Fs',Fs,'NFFT',hwelch.SegmentLength);
plot(psdPer);
figure;
plot(psdWOSA);
  1 Kommentar
Peter
Peter am 17 Okt. 2011
Thanks for the code.
Indeed, I wrote a Welch like overlapped segment analyze to calcuate a fft with a fixed frequency resolution for varying length of input data. One thing I didn't like on the original Welch script is that the overlapping data point are discarded - I put them in the last vector with the compromise that this one does not overlapp the one before exactly for 50%. I also do not like the nex power of 2-fft implemented in periodogram as far as I understood.
Is the fft the best compromize between frequency and power resolution?

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Wayne King
Wayne King am 17 Okt. 2011
The periodogram does not have to use next power of 2. Look at my example, I specified the length to be the length of the input vector. You can specify NFFT as an input argument.
Also, the Welch estimate does not discard the overlapping data points. You may lose some data at the end, but you can control that by adjusting the segment length and overlap.
For example, in my example I had an input of length 1000.
By specifying a window length of 200 and using the default noverlap of 50. The overlapped spectra were computed for
  1. 1:200
  2. 151:350
  3. 451:650
  4. 601:800
  5. 751:950
I could have easily adjusted the window length and overlap to utilize every single data point (but I don't think that buys you anything here)

Community Treasure Hunt

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

Start Hunting!

Translated by