How to design a Toeplitz matrix with negative lower triangle elements and zero main diagonal elements

2 ビュー (過去 30 日間)
I want to design a square symmetric toeplitz matriz with diagagonal elements zero and lower triangle elements should be negative
Is there any simple command or any simple coding technique to obtain this without using any loops.
The sample matrix is shown below: N*N is the size of the matrix decided by the user
0 1 2 3 - - - (N-1)
-1 0 1 2 - - - (N-2)
-2 -1 0 1 - - - (N-3)
-3 -2 -1 0 - - - (N-4)
-
-
-(N-1) -(N-2) -(N-3) -(N-4) - - - 0
  1 件のコメント
Vinay Killamsetty
Vinay Killamsetty 2019 年 10 月 1 日
I got the answer
triu(toeplitz([0,1,2,3,4,5]))+tril(toeplitz([0,-1,-2,-3,-4,-5]))
But is there any onswer simpler than this?

サインインしてコメントする。

採用された回答

Bruno Luong
Bruno Luong 2019 年 10 月 1 日
toeplitz(0:-1:-5,0:5)

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by