Advertisement
STANAANDREY

jacobi solver

Mar 5th, 2023
1,066
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MatLab 0.17 KB | None | 0 0
  1. function x = jacobi(A, b, x0, k)
  2.     D = diag(diag(A));
  3.     L = tril(A) - D;
  4.     U = triu(A) - D;
  5.     x = x0;
  6.     for i=1:k
  7.         x=pinv(D)*(b-(L+U) * x);
  8.     end
  9. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement