MATLAB: Calculating Coherence in an Matrix

coherencefieldtripMATLAB

This may be a simple quesiton, but I have been working with fieldtrip and have had difficulty with the freqanalysis function since I am processing data outside of fieldtrip synchronously.
I have a dataset that is 259 X 683000. Where each row coincides with a specific electrode on the body.
I was wondering if there was anyway to calculate coherence between the first 256 (1:256) electrodes and the final 3 (257:259).
Regards,
J

Best Answer

I am trying to answer using the following code
% Sample Array Data
data_set=rand(259,1000); %I intentionally changed the column number
%First 256 Electrodes
req_data1=data_set(1:256,:);
%Last 3 Electrodes
req_data2=data_set(257:259,:);
% Vertical Concatenation
result_data=[req_data1;req_data2];
% Next Mutual coherence of the matrix
coh_data=mutual_coherence(result_data)
The custom function mutual_coherence avalible here (please verify). You may look on other MATLAB inbuilt function, like corr,norm etc. Once you select a very large array size, a problem may arise, please refer to this answer.