[go: up one dir, main page]

Menu

[2df89a]: / init / vec2covm.m  Maximize  Restore  History

Download this file

23 lines (20 with data), 659 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
% vec2covm.m: utility to make a cov matrix out of vector representation
% GUISDAP v.1.60 96-05-27 Copyright Asko Huuskonen and Markku Lehtinen
%
% creates the covariance matrix back from the storage vector form
% Needed, as the matlab matrix elements cannot be matrices themselves
%
% See also: covm2vec
%function errmatr=vec2covm(covvec)
function errmatr=vec2covm(covvec)
len=floor(sqrt(2*length(covvec)));
errm=zeros(len,len);
er=covvec(1:len)';
ind=len;
errm=errm+diag(ones(len,1),0);
for i=1:len-1
errm=errm+diag(covvec(ind+(1:(len-i))),i);
errm=errm+diag(covvec(ind+(1:(len-i))),-i);
ind=ind+len-i;
end
errmatr=errm.*(er*er');