Clear Filters
Clear Filters

How do I recreate the wcoherence imagesc with the outputs wcoh, coi and f (without the arrows)?

4 views (last 30 days)
I can't seem to get a comparable right yaxis and coi for my data. I am using-
[wcoh,wcs,f,coi]=wcoherence(data1,data2,fs);
t=0:1/fs:(length(data1)-1)/fs;
figure; imagesc(t./60./60,f,wcoh);
hold on; plot(t./60./60,coi,'--w','LineWidth',2);
set(gca,'YDir','normal');
My yaxis and coi (figure2) don't match what I get when using wcoherence (figure1) to plot.
Any help would be great! Thanks!

Answers (1)

Abhimenyu
Abhimenyu on 13 Oct 2023
Hi Deepshikha,
I understand that you are using “wcoherence” function to compute the wavelet coherence and cross-spectrum of two signals, and then plotting the results using “imagesc” and “plot”.
To ensure that the y-axis and the cone of influence (COI) match in the plot, the y-axis limits must be set correctly using the “ylim” function as shown in the example code below:
Shape[wcoh,wcs,f,coi]=wcoherence(data1,data2,fs);
t=0:1/fs:(length(data1)-1)/fs;
% Plot the coherence
figure;
imagesc(t./60./60,f,wcoh);
set(gca,'YDir','normal');
% Adjust the y-axis limits
ylim([min(f) max(f)]);
hold on;
% Plot the cone of influence (COI)
plot(t./60./60,coi,'--w','LineWidth',2);
% Adjust the y-axis limits for the COI
ylim([min(f) max(coi)]);
% Add labels and title
xlabel('Time (hours)');
ylabel('Frequency');
title('Wavelet Coherence');
% Add colorbar
colorbar;
Please refer to the following documentation link below for more information on ylim” function,
I hope this helps!
Thank you,
Abhimenyu.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!