How to write pentadigonal matix?
古いコメントを表示
How to generate the following penta diagonal matrix in matlab?

採用された回答
その他の回答 (1 件)
Bruno Luong
2020 年 7 月 27 日
編集済み: Bruno Luong
2020 年 7 月 27 日
m = 4;
n = 3*m;
T = diag(ones(1,n-3),3);
A = T + T';
B = ones(3)-5*eye(3);
A = A + kron(eye(m),B)
1 件のコメント
Bruno Luong
2020 年 7 月 27 日
編集済み: Bruno Luong
2020 年 7 月 27 日
If you insist on for loop
m = 4;
n = 3*m;
T = diag(ones(1,n-3),3);
A = T + T';
B = ones(3)-5*eye(3);
for k=1:m
i = (k-1)*3+(1:3);
A(i,i) = B;
end
A
カテゴリ
ヘルプ センター および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
