using conofinf to plot the cone of influence in a imagesc(time, freq, coeffs)
Show older comments
Hello there
I have done the cwt of a signal
coeffs=cwt(signal, scales, wavelet)
scales are obtained as this: freq=1:1: 1000 Hz
then I do the freq2scale conversion (my own routine very obvious)
scales=centfrq(wavename)./(freq*(1/fs));
so I end up having a vector of scales not equaly spaced (1/x rule)
However I want the plot to be related to the freq in Hz, so:
imagesc(time, freq, abs(coeffs)) ---works fine!!
Now I would want to put in this plot the limits of the influence cone by doing
[PLmin,PRmax] = conofinf(wavename,scales,length(x),[]);
just doing [cone] = conofinf(wavename,scales,length(x),[]); will not work because my imagesc is ploted with time versus pseudo-frquencies.
Note that scales is a non-linear vector
How do I go about putting a cone of influence in the above imagesc plot?
many regards´ para
4 Comments
Maria
on 27 Aug 2015
Hi, I don't know if it's still useful. But here's what I did when I had the same problem:
LenSig = length(signal);
wname = 'morl'
% construct your freq. vector
freq=1:1:1000;
% transform to scales
Fc = centfrq(wname);
scales = Fc./(f*dt);
% get wavelet transform
coefs = cwt(sig,scales,wname);
S = abs(coefs.*conj(coefs));
WT = S./N;
% plot wavelet transform / scalogram
figure;
imagesc(t,freq,WT);
axis square;
colorbar;
% annotate axes and title
title('Coefficients of continuous wavelet transform');
xlabel('Time');
ylabel('Pseudo-frequency');
% get cone of influence
% Here, you have to specify points at which you want to calculate COI
% as the last parameter:
cone = conofinf(wname,scales,LenSig,[1 LenSig]);
% combine left and right edges
cone = [cone{1}(:,floor(1:LenSig/2)) cone{2}(:,ceil(LenSig/2):end)];
% previous steps give you an area under COI
% you can see it with: figure; imagesc(cone);
% now, we want to get the border of this area
coi = zeros(1,LenSig);
for idx = 1:LenSig
valcoi = find(cone(:,idx)==1,1,'last');
if ~isempty(valcoi)
coi(idx) = f(valcoi);
end
end
% now plot COI border on top of your wavelet transform
hold on;
plot(t,coi,'k','LineWidth',1.5);
hold off;
Optionally, you can hatch the area under COI, but it's a bit of a hack and it's not ideal. For this you will need hatchfill function. Once you have this function on your path, you can use it like this:
[~,h] = contourf(t,freq,cone*max(WT(:)),[1 1]*max(WT(:)));
hPatch = findobj(h, 'Type', 'patch');
hh = hatchfill(hPatch, 'cross', 45, 10);
I also constructed frequency vector and computed scales from it. This method worked fine for me.
chin-leong wooi
on 13 Oct 2015
Edited: chin-leong wooi
on 13 Oct 2015
May i ask what is the variable of t and N? and what are the function f(valcoi)?
Paramonte
on 11 Apr 2016
Safura Sobri
on 14 Nov 2020
What is the variable for N?
Answers (1)
Paramonte
on 10 Feb 2014
0 votes
Categories
Find more on Continuous Wavelet Transforms in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!