[Scilab-users] spatial correlation coefficient: Is the MATLAB corrcoef function doing the job?

Rafael Guerra jrafaelbguerra at hotmail.com
Thu Feb 8 18:55:11 CET 2018


Hi Heinz,



Scilab computes the covariance matrix and from which the correlation matrix can be obtained using formula in https://en.wikipedia.org/wiki/Covariance_matrix



Check implementation below:


//START OF CODE
// https://en.wikipedia.org/wiki/Covariance_matrix
function Y=corrmatrix(M)
    C = cov(M);  // covariance matrix
    D = sqrt(diag(C)); // standard deviations
    D = inv(diag(D));
    Y = D*C*D;  // correlation matrix
endfunction

M = grand(9,3,"def")
M(:,2) = M(:,1)*2;
Y = corrmatrix(M);
disp(M,"M")
disp(Y,"Y")
// END OF CODE



Regards,

Rafael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180208/510b66a9/attachment.htm>


More information about the users mailing list