How to plot a cone of influence with the old CWT version?

8 visualizzazioni (ultimi 30 giorni)
I am a wavelets analysis beginner. I would like to use continuous wavelet transform (CWT) to time-frequency analyze signals in our experiment. I have done the CWT of a signal with the new CWT version and the cone of influence can be achieved automatically in the scalogram. However, only three wavelets can be chosen in the new CWT version, far less than the old CWT version. I would like the old one. So how can I plot a cone of influence using the old CWT version?
Here is a CWT code of a cosine signal, as a example, with the old CWT version and the new CWT version, respectively:
clear all,clc
fs=1024;
x=0:1/fs:1;
y=cos(2*pi*100.*x);
figure
plot(x,y)
title('original signal')
%%%%%%% old CWT version %%%
wavename='cmor4-4';
totalscal=256;%scale length
fc=centfrq(wavename);
cparam=2*fc*totalscal;
a=1:1:totalscal;
scal=cparam./a;
f=scal2frq(scal,wavename,1/fs);
coefs=cwt(y,scal,wavename,1/fs);
figure
imagesc(x,f,abs(coefs)); %% how to plot the COI with the old version??
title('old CWT version without COI')
%%%% new CWT version %%%%%
figure
[wt,ff,coi]=cwt(y,'morse',fs);
pcolor(x,ff,abs(wt));shading interp
hold on
plot(x,coi,'r')
title('new CWT version with COI')

Risposte (1)

Suraj Kumar
Suraj Kumar il 25 Mar 2025
To plot the cone of influence(COI) with the old CWT version you can manually calculate the COI and then plot it.You can refer to the following steps along with the attached code snippets for better understanding:
1. You can select a wavelet and define the scale length for the CWT.Then you can use the "cwt" function with the defined wavelet and scales to compute the wavelet coefficients.
fs = 1024;
x = 0:1/fs:1;
y = cos(2*pi*100.*x);
wavename = 'cmor4-4';
totalscal = 256;
fc = centfrq(wavename);
cparam = 2 * fc * totalscal;
a = 1:1:totalscal;
scal = cparam ./ a;
f = scal2frq(scal, wavename, 1/fs);
coefs = cwt(y, scal, wavename, 1/fs);
2. Then you can compute the COI by using the formula "sqrt(2) * scal2frq(1 ./ scal, wavename, 1/fs)". Ensure the COI is interpolated to match the dimensions of the time vector "x".
coi = sqrt(2) * scal2frq(1 ./ scal, wavename, 1/fs);
coi = interp1(linspace(x(1), x(end), length(coi)), coi, x, 'linear', 'extrap');
3.Plot the CWT scalogram using "imagesc" function in MATLAB and then overlay the COI as a dashed line to indicate the region affected by edge effects.
figure;
imagesc(x, f, abs(coefs));
axis xy;
hold on;
h_coi = plot(x, coi, 'r--', 'LineWidth', 2);
legend(h_coi, 'Cone of Influence', 'Location', 'best');
title('Old CWT Version with COI');
xlabel('Time (s)');
ylabel('Frequency (Hz)');
colormap jet;
colorbar;
To learn more about the "cwt" or "imagesc" functions in MATLAB, please refer to the following documentation links:
Hope this resolves your query!

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by