|
Sorry, reposted to "answers," my mistake.
"Sam" wrote in message <jtn33t$9u6$1@newscl01ah.mathworks.com>...
> Hello,
>
> I am trying for the first time to use matlab to calculate coherence between every possible pair of sensors across a lot of timepoints. I need to compare each pair at a number of windows of data. I am running into efficiency issues. I am assume this is a simple vectorization problem, but I haven't done vectorization before and don't want to mess it up, and would thus appreciate your help in at least learning the principles at play.
>
> My first step in optimizing was to make the second loop go from i:n, because coherence is symmetric. This cut down half of the calculations, but it is still very very slow.
>
> data_coh = cell(nwindows, n,n);
> data_fq = cell(nwindows, n, n);
>
> for i = 1: n;
> for j = i: n;
> for k = 1:nwindows;
> [gcoh,gfqr] = mscohere(datapoint(i).win(k).time, datapoint(j).win(k).time);
> data_coh{k,i,j} = gcoh;
> data_coh{k,j,i} = gcoh;
> data_fq{k,i,j} = gfqr;
> data_fq{k,j,i} = gfqr;
> end
> end
> end
>
> Thanks so much!
|