Clear Filters
Clear Filters

Writing a Nth order matrix.

2 views (last 30 days)
JA
JA on 11 Aug 2016
Edited: Stephen23 on 11 Aug 2016
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.

Accepted Answer

Stephen23
Stephen23 on 11 Aug 2016
Edited: Stephen23 on 11 Aug 2016
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

More Answers (0)

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!