How to obtain time-averaged wavelet spectral density by the new version of CWT?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Shen Shen
am 28 Jan. 2024
Kommentiert: Shen Shen
am 9 Mai 2024
I know how to obtain time-averaged wavelet spectral density by the old version of CWT, and the result is similar to the power spectral density (PSD) by function PWELCH. But how to obtain wavelet spectral density by the new version of CWT? Given that the old version is no longger recommended. Thank you. Here is the code and signal I used.
load u.mat
Fs=800; % sampling frequency of signal 'u', in Hz;
% PSD by pwelch
SegOvlp=75;
windowL=1024;
window=hamming(windowL);
noverlap=fix(SegOvlp/100*windowL);
nfft=windowL;
[pu_F,f]=pwelch(u,window,noverlap,nfft,Fs);
Pu_F=pu_F*var(u)/trapz(f,pu_F); %normalization
% WSD by old version of CWT, which gives similar results to pwelch
wavename='gaus3';
wcf=centfrq(wavename);
fre=10.^(linspace(-0.11,2.6,100));
scal=wcf*Fs./fre;
coefs=cwt(u,scal,wavename);
pu_w=sum(abs(coefs).^2,2)/Fs;
Pu_w=pu_w*var(u)/abs(trapz(fre,pu_w)); %normalization
% figure
loglog(f,Pu_F,'k');
hold on
loglog(fre,Pu_w,'r');
xlabel('\itf/Hz');ylabel('\itPSD');
legend('PSD','WSD by old CWT')
set(gcf,'Units','centimeters','Position',[10 5 15 8]);
set(gcf,'Color','w');
set(gcf, 'PaperPositionMode', 'auto');
0 Kommentare
Akzeptierte Antwort
Wayne King
am 6 Mai 2024
Hi Shen, you can use cwtfilterbank and then use the timeSpectrum method (function). If you want scale-averaged power, then scaleSpectrum is also available.
Note both methods accept either the raw time series data, or the CWT coefficient matrix.
For example:
load kobe
% Construct filterbank object. Only required input is length of data
% but see the reference page for all the properties you can specify
fb = cwtfilterbank(SignalLength=length(kobe));
[tavgp,f] = fb.timeSpectrum(kobe);
semilogx(f,tavgp)
grid on
xlabel('Frequency (Hz)')
ylabel('Power')
% There is also a convenience plot syntax which may provide a convenient
% visualization for you. Call the methods with no output arguments
figure
fb.timeSpectrum(kobe);
% As I said, if you want you, you can compute the CWT coefficients separately and
% input those
cfs = fb.wt(kobe);
figure
fb.timeSpectrum(cfs);
I would recommend the following help pages:
Note there are normalization options under timeSpectrum. Hope that helps,
Wayne
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Continuous Wavelet Transforms finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!