MATLAB: How to make a lower triangular matrix from a column vector

matrix manipulation

I am trying to make a lower triangular matrix from a column vector to then produce a fully populated 24×24 symmetric matrix.
The column vector I'm using (A as a simple example) has 300 elements and I need to populate the triangular matrix (B as a simple example) as follows:
A = [i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 …]
B = [i1; i2 i3; i4 i5 i6; i7 i8 i9 i10; ….]
Any help would be appreciated. It may be that it's easier to make the symmetric matrix straight away, if so I'm open to suggestions. Thanks in advance.

Best Answer

Create the symmetric matrix directly:
n = 24;
Ind = zeros(n, n);
Ind((1:n) >= (1:n).') = 1:300;
Ind = Ind + Ind.' - diag(diag(Ind));
B = A(Ind);
Related Question