How do I calculate the coherence within a specific frequency range?
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am calculating the wavelet transform coherence betweem two signals. I am trying to extract the average coherence between 0.01-1Hz. I have tried using the f output of the wcoherence() function however, I'm confused by this output becasure it is a matrix of complex numbers that are both positive and negative. In the plot, I can clearly see that there are values within this frequency fange however, the current approach I'm using returns NaN or the values increase linearly with the increasing frequency band which does not seem correct.
How do I extract the average coherence within this frequency range?
Here is the code I am currently using:
load('x') % load signal 1
load('y') % load signal 2
fs = 10; % 10 Hz sampling rate
[wtc, f, coi] = wcoherence(x, y,fs); % calculate the coherence between the signals
fbandStep = 0.05; % frequency step for defining the frequency bands to calculate average coherence
for k = 0.01:0.05:1-fbandStep
% define upper and lower frequency bounds
lowerFrequencyBound = k;
upperFrequencyBound = k+fbandStep;
% Find indices corresponding to the frequency range
freqIndices = find(f_trial >= lower & f_trial <= upper);
% Extract coherence values for the specific frequency range
avgCoherence(k) = mean(wtc_trial(freqIndices));
clear freqIndices
end
1 comentario
Mathieu NOE
el 14 de Nov. de 2023
hello
seems to me there is a bug in your code
[wtc, f, coi] = wcoherence(x, y,fs); % calculate the coherence between the signals
should be
[wtc, wcs, f, coi] = wcoherence(x, y,fs);
according to the doc , this is the right way :
[wcoh,wcs,f] = wcoherence(x,y,fs)
[wcoh,wcs,f,coi] = wcoherence(x,y,fs)
Respuestas (0)
Ver también
Categorías
Más información sobre Frequency Transformations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!