MATLAB: Correlation of an array

correlation of an array.

i've an array in which i've stored different matrices. i want to calculate the correlation between the matrices stored in an array
like:
A=[ 12 23 12 34 21 32 43 65 65 76 1 23 43 21 54 98 ]
21 43 2 13 76 87 34 22 89 67 45 88 55 77 54 65
32 45 56 78 89 87 84 54 22 33 43 54 78 98 97 65
67 54 33 44 88 77 66 54 21 15 16 48 90 80 21 66
like if i've array=[A;B;C;D]
i want the correlation between A and B
correlation between A and C
correlation between A and D
correlation between B and C
correlation between B and D
correlation between C and D
help me in doing so

Best Answer

Extract the 4 submatrices and correlate all the permutations.
A = fullMatrix(:, 1:4);
B = fullMatrix(:, 5:8);
C = fullMatrix(:, 9:12);
D = fullMatrix(:, 13:16);
% Now correlate:
AB = xcorr2(A, B);
AC = xcorr2(A, C);
AD = xcorr2(A, D);
BC = xcorr2(B, C);
BD = xcorr2(B, D);
CD = xcorr2(C, D);
There is no need for complicated loops when you have this few matrices, and just a few simple lines of code will do it for you.