Help needed script frequency
显示 更早的评论
Dear Community
I have created a loop to get phase synchronization for frequency range from 4-8 hz, but for some reason the script calculates only the value for 8Hz.
What am I doing wrong?
% phase-based connectivity
load 'EC_I.mat'
% names of the channels you want to compute connectivity between
channel1 = 'Fz';
channel2 = 'F8';
% create complex Morlet wavelet
frequencies = [4:8];
time = -1:1/EEG.srate:1;
half_wavN = (length(time)-1)/2;
all_wavelet = zeros(10, 1001);
for i_frequencies = frequencies
center_freq = i_frequencies ;
wavelet = exp(2*1i*pi*center_freq.*time) .* exp(-time.^2./(2*(4/(2*pi*center_freq))^2))
all_wavelet(i_frequencies,:) = wavelet ;
end
all_phase_synchronization = zeros(1, 1000);
for i_frequencies = frequencies
center_freq = i_frequencies ;
phase_synchronization = abs(mean(exp(1i*(phase_data(2,:)-phase_data(1,:)))));
all_phase_synchronization(i_frequencies,:) = phase_synchronization ;
end
disp([ 'Synchronization between ' channel1 ' and ' channel2 ' is ' num2str(phase_synchronization) '!' ])
All tips would be very helpful!! Thanks in advance,
Carmen
3 个评论
Walter Roberson
2021-6-30
for i_frequencies = frequencies
center_freq = i_frequencies ;
phase_synchronization = abs(mean(exp(1i*(phase_data(2,:)-phase_data(1,:)))));
all_phase_synchronization(i_frequencies,:) = phase_synchronization ;
end
frequences is 4:8 and you are setting i_frequencies to those. So i_frequencies is content, not index. You will end up writing to all_phase_synchronization(4:8,:) rather than to all_phase_synchronization(1:5, :)
Carmen Sergiou
2021-6-30
Carmen Sergiou
2021-6-30
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Wavelet Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!