Creating triangular matrix from a vector (with a twist)

2 ビュー (過去 30 日間)
Catalin
Catalin 2015 年 9 月 7 日
回答済み: Matt J 2015 年 9 月 7 日
I have a vector v=[a b c d] and I want to (efficiently) create a matrix of the form : M=[a 0 0 0 ; b a 0 0 ; c b a 0 ; d c b a ]. I am experimenting with "diag" function but it does not seem to be very efficient. Any thoughts?

採用された回答

Matt J
Matt J 2015 年 9 月 7 日
>> toeplitz([1 2 3 4],[1,0,0,0])
ans =
1 0 0 0
2 1 0 0
3 2 1 0
4 3 2 1

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by