How to make a tridiagonal matrix (N-1)*(N-1), with different values in the first row?
3 ビュー (過去 30 日間)
古いコメントを表示
回答 (2 件)
Torsten
2023 年 5 月 15 日
Change the two values manually after you created A with the "standard" diagonal vectors.
A = ...;
A(1,1) = A(1,1) + 4/3;
A(1,2) = A(1,2) - 1/3;
...
0 件のコメント
Steven H
2023 年 5 月 15 日
A = (-2 + 16*h^2)*eye(n-1); % Create the diagonal
I = [2:n:numel(A), n:n:numel(A)]; % Indices of off-diagonal elements
A(I) = 1; % Set values to one
A(1,1:2) = A(1,1:2) + [4/3, -1/3]; % Change values in first row
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!