|
a = detrend(A,'constant');
b = detrend(B,'constant');
C = sum(a.*b)./sqrt(sum(a.*a).*sum(b.*b));
On Monday, March 21, 2005 2:26:41 PM UTC-8, M wrote:
> hi there,
>
> i have two matrices,A and B.
> each column of matrix A corresponds to a column of matrix B.
> what i want is the correlation coefficient of the corresponding
> columns.
>
> i could do it like this:
>
> for i=1:size(A,2)
> temp=corrcoef(A(:,i),B(:,i))
> C(i)=temp(1,2);
> end
>
> the problem is that i want to somehow remoe the for lopp as it is
> very time consuming. and the size of my matrices are really huge!
>
> can you think of any way that i can vectorize this solution?
>
> thanks,
> M
|