view m-toolbox/classes/+utils/@math/corr2cov.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 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