Info
此问题已关闭。 请重新打开它进行编辑或回答。
Why do I keep getting an infinity loop when I try to implement the Jacobi method?
1 次查看(过去 30 天)
显示 更早的评论
I derived B from this linear system:
1a - 1b + 2c= 8
1a + 1b + 2c = 10
1a + 0b + 1c = 2
clear all;clc;
c=[8 10 2]';
B= [0 1 -2;-1 0 -2;-1 0 0];
tol = 10^(-10);
x0=[1,1,1]'; x(:,1)= x0;
k=1;
while 1
xnew(:,k+1) = (B*x(:,k)) + c;
if norm(xnew(:,k+1)-x(:,1)) < tol
break;
end
x=xnew;
k=k+1;
end
k
1 个评论
Walter Roberson
2015-12-6
How the heck does your B array relate to the system of equations you indicate? And why are you adding c instead of subtracting it?
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!