Mercurial > hg > ltpda
diff m-toolbox/classes/+utils/@math/corr2cov.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/+utils/@math/corr2cov.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,31 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% CORR2COV +% Convert correlartion matrix to covariance matrix +% +% SigC Vector of length n with the standard deviations of each process. n +% is the number of random processes. +% +% CorrC n-by-n correlation coefficient matrix. If ExpCorrC is not +% specified, the processes are assumed to be uncorrelated, and the identity +% matrix is used. +% +% Algorithm +% +% Covar(i,j) = CorrC(i,j)*(SigmC(i)*SigmC(j) +% +% L Ferraioli 10-10-2010 +% +% $Id: corr2cov.m,v 1.1 2010/11/16 16:41:37 luigi Exp $ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +function Covar = corr2cov(CorrC,SigC) + + Covar = CorrC; + + for tt=1:size(CorrC,1) + for hh=1:size(CorrC,2) + Covar(tt,hh) = CorrC(tt,hh)*SigC(tt)*SigC(hh); + end + end +end \ No newline at end of file