How to make the main diagonal and the diagonal above and below the main diagonal equal to -2 and 1 respectively
12 ビュー (過去 30 日間)
古いコメントを表示
回答 (1 件)
Andrei Bobrov
2019 年 3 月 19 日
編集済み: Andrei Bobrov
2019 年 3 月 19 日
A = gallery('tridiag',100,-1,2,-1);
or
n = 100;
A = spdiags(ones(n,1)*[-1 2 -1],-1:1,n,n);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operating on Diagonal Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!