I have the following code:
for k = 1:256
for t = 1:10000
% R matrix
buffer = corrcoef(matrixA(:,k),matrixB(:,t));
correlation_matrix(k,t) = buffer (2,1);
end
end
I calculate the pearson correlation of the columns of two matrices. This works fine for me and the results are correct. However the process seems to be very very slow. Does anyone have an idea how to accelerate the calculations here?
You can remove the loop entirely by using
corr
from the stats toolbox