How to write this matrix better?

Since this matrix has some pattern to it, must be a nicer way to write it? Thanks

1 件のコメント

dpb
dpb 2016 年 5 月 1 日
編集済み: dpb 2016 年 5 月 1 日
Edit it to align it so it's clearly legible what the pattern is--too hard to keep columns straight as is, sorry...but using diag and friends may be of some help.

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

 採用された回答

Roger Stafford
Roger Stafford 2016 年 5 月 1 日
編集済み: Roger Stafford 2016 年 5 月 1 日

0 投票

k = 1e6*(diag(s(1:22),1)+diag(s(1:22),-1)+...
diag(-[s(1:22),0]-[0,s(1:22)]));
I am assuming s is a row vector here. Make the obvious change if it is a column vector.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGet Started with MATLAB についてさらに検索

質問済み:

2016 年 5 月 1 日

コメント済み:

2016 年 5 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by