function [R2]=correlation2(A,B)
% correlation2 calculates the elementwise squared correlation of two
% matrices
    if size(A)~=size(B)
        error('dimension mismatch')
    end
    R2=zeros(size(A,2),1);
    for i=1:size(A,2)
        R2(i)=corr(A(:,i),B(:,i)).^2;
    end
end