How to obtain time-averaged wavelet spectral density by the new version of CWT?
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Wayne King
2024-5-6
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Continuous Wavelet Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!