If I have a vector
A = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]
Is there any way to convert this to a matrix
[0 2 5 9 14
1 4 8 13 0
3 7 12 0 0
6 11 0 0 0
10 0 0 0 0 ]
For vector A of length 2016.
So far:
n = 63;
B = triu(true(n));
C = zeros(n);
C(B) = A;
Looks to be on the right line.
Then to try and create vector D whereby each column is the diagonal of matrix C...
D = zeros(n);
for i = 1:n;
D(:,i) = diag(C,i-1);
end
But on the second iteration the length of the diagonal does not fill an entire column (as expected and desired) and I get a dimension mismatch error.