How do I recreate the wcoherence imagesc with the outputs wcoh, coi and f (without the arrows)?
3 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
Abhimenyu
2023-10-13
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.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!