필터 지우기
필터 지우기

How do I calculate the coherence within a specific frequency range?

조회 수: 10 (최근 30일)
FsC
FsC 2023년 11월 13일
댓글: Mathieu NOE 2023년 11월 14일
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
Mathieu NOE
Mathieu NOE 2023년 11월 14일
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)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Frequency Transformations에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by