Writing a Nth order matrix.

3 ビュー (過去 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 Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by