I am trying to change a column vector
p=[1;3;5]
into a square matrix P=[1,3;3,5]
Howevery I only manage to change the column vector p into a square matrix with element [1,0;3,5]
with the following code
p=[1;3;5]n=2P = zeros(n);P(triu(ones(n)) == 1) = p;P
Best Answer