% convert Covariance matrix into Standard deviation correlation matrix S_rho = sugr_covariance_2_sigma_rho(C) Wolfgang Förstner wfoerstn@uni-bonn.de
0001 %% convert Covariance matrix into Standard deviation correlation matrix 0002 % 0003 % S_rho = sugr_covariance_2_sigma_rho(C) 0004 % 0005 % Wolfgang Förstner 0006 % wfoerstn@uni-bonn.de 0007 0008 function S_rho = sugr_covariance_2_sigma_rho(C) 0009 0010 n = size(C, 1); 0011 disp(['sigma_average: ', num2str(sqrt(trace(C) / n))]); 0012 sigma_average = sqrt(trace(C) / n); 0013 S_rho = zeros(n,n); 0014 for i = 1:n 0015 S_rho(i, i) = sqrt(C(i, i)) / sigma_average; 0016 for j = 1:n 0017 if i ~= j 0018 S_rho(i, j) = C(i, j) / sqrt(C(i, i) * C(j, j)); 0019 end 0020 end 0021 end 0022 0023