I need to calculate time-evolving power spectral density using Matlab periodogram function
Afficher commentaires plus anciens
I need to calculate time-evolving power spectral density using Matlab periodogram function based on Welch theory to estimate the PSD of a moving 400-kyr boxcar filter with an overlap of 85%. In all the figures, values have to be plotted at the center of each 400-kyr window over which they are calculated.
Réponse acceptée
Plus de réponses (2)
Wayne King
le 16 Mar 2013
Modifié(e) : Wayne King
le 16 Mar 2013
If you want to use Welch's method in a time-evolving manner, use buffer() to segment the signal with overlap and obtain Welch estimates on those overlapped segments.
I would caution you against using a boxcar filter, here I'll give you an example with a Hamming window. You can substitute your boxcar filter as needed.
Further, you have not been clear about whether the overlap of 85% applies to both the time-evolving PSD or the overlap in the Welch's estimate, I'll use 50% for the latter.
Fs = 1000;
t = 0:0.001:4-0.001;
x = cos(2*pi*10*t)+randn(size(t));
winsize = 200;
numoverlap = round(0.85*winsize);
win = hamming(200);
X = buffer(x,200,numoverlap);
for nn = 1:size(X,2)
[Pxx(:,nn),F] = pwelch(X(:,nn),win,length(win)/2,length(win),Fs);
end
The columns of Pxx give you the time-varying Welch PSD estimates. You may want to avoid using the last column of Pxx because that is computed on the last column of X, which may contain a lot of zeros.
1 commentaire
Biljana basarin
le 17 Mar 2013
Wayne King
le 18 Mar 2013
Modifié(e) : Wayne King
le 18 Mar 2013
Just use surf(), you can easily work out a "meaningful" time vector but you have to look at the why buffer() has prepended and appended zeros to get the matrix right.
Fs = 1000;
t = 0:0.001:4-0.001;
x = cos(2*pi*10*t)+randn(size(t));
winsize = 200;
numoverlap = round(0.85*winsize);
win = hamming(200);
X = buffer(x,200,numoverlap);
for nn = 1:size(X,2)
[Pxx(:,nn),F] = pwelch(X(:,nn),win,length(win)/2,length(win),Fs);
end
surf(1:size(Pxx,2),F,10*log10(abs(Pxx)),'EdgeColor','none');
axis xy; axis tight; colormap(jet); view(0,90);
xlabel('Time');
ylabel('Frequency (Hz)');
1 commentaire
Biljana basarin
le 18 Mar 2013
Catégories
En savoir plus sur Spectral Estimation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!