From: Matthew on
I'm writing a script to perform a moving correlation of two signals. Basically I have one large signal ans several smaller chunks that should line up somewhere. So I just use corr to test the test signal against the first part of the reference signal, then move it one index to the right and repeat. To speed this up, I am parallelizing it like so:


parfor i=1:ref_length-test_length
correlation(i) = corr(test_signal,reference_signal(i:i+test_length-1),'rows','pairwise');
offset(i) = i;
end

I think the variable names are self explanatory enough.

My problem is that the reference_signal variable is not sliced, and I'm having problems thinking of a way to slice it without taking up a very large amount of memory. The large data set (reference_signal) is roughly 10^5 points and each small set (test_signal) contain roughly 10^3. I'm not even sure if I could allocate that much memory.

So, is there a way to optimize this loop or should I just live with it. I have profiled the code with and without the parfor and the parallel method does show a 2% speed up.