Writing a Nth order matrix.

1 次查看(过去 30 天)
JA
JA 2016-8-11
编辑: Stephen23 2016-8-11
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.

采纳的回答

Stephen23
Stephen23 2016-8-11
编辑:Stephen23 2016-8-11
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by