MATLAB: Writing a Nth order matrix.

matrixmatrix arraymatrix manipulation

I want to create a ' nxn' matrix but it's not an identity matrix. As I don't know how to write matrix on Matlab Answers, I created them on latex and took screenshots, hopefully that's sufficient .The type of matrix i want to create is:
Where the coefficients a1, a2,…… an are known, and basically the order of matrix n is nothing but length(a)
few example of what i mean:
.
The only condition being n >= 2, because if n = 1, then the whole concept falls apart. I am kinda blank on how to proceed with these kinda matrix.

Best Answer

Just keep it simple:
>> a = 1:5;
>> M = diag(ones(1,numel(a)-1),1);
>> M(end,:) = a
M =
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
1 2 3 4 5