MATLAB: How to make a symmetric matrix

challangeMATLABmatrixsymmetric

hey,
the assiment is a challange
-to create this matrix in one row of code by using Matlab methods ( also multiplying metrix and Vectors are permited ).
i cant write the matrix directly(also simple operations
example:
[1;1;1]+[2;2;2] to get [3;3;3].)
my wish to get the specific matrix:
B = [1 2 3 8 1 6 ; 2 1 0 3 5 7; 3 0 1 4 9 2; 8 3 4 1 0 3 ; 1 5 9 0 1 2; 6 7 2 3 2 1]
my intuition is to found some legality or somthing like that, and to use it to get a simple solution(1 row with the shortest way.).
B =
1 2 3 8 1 6
2 1 0 3 5 7
3 0 1 4 9 2
8 3 4 1 0 3
1 5 9 0 1 2
6 7 2 3 2 1

Best Answer

... make a symmetric matrix:
M = tril(randi([0 9],6),-1);
B = M + M' + eye(6);
Maybe use function toeplitz:
B = toeplitz(randi([0 9],6,1));