0001 function [cross_trial,fft_trial] = csdm(trialdata) 0002 0003 trialdata = zeromean(trialdata); 0004 fft_trial = fft(trialdata)./(size(trialdata,1)+1); 0005 cross_trial = zeros(fix(size(trialdata,1)/2),(size(trialdata,2).^2+size(trialdata,2))/2); 0006 icount = 1; 0007 0008 if strcmp(computer, 'MAC2') 0009 for i = 1:size(trialdata,2) 0010 for j = i:size(trialdata,2) 0011 cross_trial(:,icount) = ppc_cmplx_mult(fft_trial(1:fix(size(trialdata,1)/2),i),conj(fft_trial(1:size(trialdata,1)/2,j))); 0012 icount = icount+1; 0013 end; 0014 end; 0015 else 0016 for i = 1:size(trialdata,2) 0017 for j = i:size(trialdata,2) 0018 cross_trial(:,icount) = fft_trial(1:fix(size(trialdata,1)/2),i).*conj(fft_trial(1:fix(size(trialdata,1)/2),j)); 0019 icount = icount+1; 0020 end; 0021 end; 0022 end