How do I show this matrix in Matlab?
1 view (last 30 days)
Show older comments
n=50000
0 Comments
Answers (1)
the cyclist
on 3 Oct 2021
N = 5;% Change this to 50000 for your case
a = 3;% The diagonal value
b = -1;% The off-diagonal value
% Create the matrix
M = diag(a*ones(1,N)) + diag(b*ones(1,N-1),1) + diag(b*ones(1,N-1),-1);
% Create the vector
v = [2; ones(N-2,1); 2];
% Solve [See //www.tatmou.com/help/matlab/ref/mldivide.html for details]
x = M\v
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!