MATLAB: Constructing symatrical matrix out of vector

matrixmatrix multiplicationvectorvector multiplication

Hello all,
I have a question,
I have a vector that is previously vectorized out of a symatrical matrix and has the following form. (lengt 1 x L(L+1)/2 )
v = 1, 2*6, 2*7, 2*8, 2*9, 2, 2*10, 2*1,1 2*12, 3, 2*13, 2*14, 4, 2*15, 5
I now want to obtain the same matrix as before (Matrix H) of the underneath form (lengt L x L). How can I obtain this matrix out of above vector?
H =
1 6 7 8 9
6 2 10 11 12
7 10 3 13 14
8 11 13 4 15
9 12 14 15 5
thanks in advance

Best Answer

v = [1, 2*6, 2*7, 2*8, 2*9, 2, 2*10, 2*11 2*12, 3, 2*13, 2*14, 4, 2*15, 5]
% |
% I assume the comma here in your example was a typo
m = tril(ones(5))
m(m==1) = v
m = (m + m.')/2