What is a fast way to compute column by column correlation in matlab

前端 未结 2 777
粉色の甜心
粉色の甜心 2021-02-03 11:44

I have two very large matrices (60x25000) and I\'d like to compute the correlation between the columns only between the two matrices. For example:

corrVal(1) = c         


        
2条回答
  •  轮回少年
    2021-02-03 12:01

    I think the obvious loop might be good enough for your size of problem. On my laptop it takes less than 6 seconds to do the following:

    A = rand(60,25000);
    B = rand(60,25000);
    n = size(A,1);
    m = size(A,2);
    
    corrVal = zeros(1,m);
    for k=1:m
        corrVal(k) = corr(A(:,k),B(:,k));
    end
    

提交回复
热议问题