Create a matrix with non zero entries on the diagonal and subdiagonal and zero elsewhere

2 ビュー (過去 30 日間)
Zhukun Wang
Zhukun Wang 2021 年 3 月 4 日
回答済み: David Hill 2021 年 3 月 4 日
I am confused on how to generate a 4 by 4 matrix which has ones on the diagonal and zeroes on the lower subdiagonal right beneath the diagonal and 2s on the subdiagonal right above the diagonal. In addition, there should be 0 entries elsewhere.
  1 件のコメント
James Tursa
James Tursa 2021 年 3 月 4 日
What have you done so far? What specific parts of your code are you having problems with?

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

回答 (1 件)

David Hill
David Hill 2021 年 3 月 4 日
eye(4)+diag([2 2 2],1);

カテゴリ

Help Center および File ExchangeOperating on Diagonal Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by