필터 지우기
필터 지우기

How to obtain time-averaged wavelet spectral density by the new version of CWT?

조회 수: 3 (최근 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');

채택된 답변

Wayne King
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
  댓글 수: 1
Shen Shen
Shen Shen 2024년 5월 9일
Wayne, thanks so much for your prompt reply. It does help. However, a new problem appears. And I will have to bother you.
I have tried 'timeSpectrum' with both my data and the 'kobe' data. I found that the spectral results obtained by 'timeSpectrum' and 'pwelch' are so different, whatever normalization options are used under timeSpectrum. The 'spectrum' by 'timeSpectrum' seems different from the power spectral density? I'm confused. Is it possible that you may give a clue on this?
load kobe
figure(1)
fb = cwtfilterbank(SignalLength=length(kobe));
fb.timeSpectrum(kobe);
figure(2)
pwelch(kobe);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Continuous Wavelet Transforms에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by