Chris - please describe what the problem is. Are you observing any errors and, if so, what are they?
Gauss-Siedel Method
1 次查看(过去 30 天)
显示 更早的评论
I'm trying to switch my Jacobi method to Gauss-Siedel, but I'm struggling to fix it right now. Could I have some help please?
format long;
A = [9 1 1;
2 10 3;
3 4 11];
b = [10;
19;
0];
x = [0;
0;
0];
%z = [0,x'];
%for k=1:10
%x = A*x + b;
%z = [k,x'];
%end
%pause
x1 = 0.0; x2 = 0.0; x3 = 0.0;
z = [0,x1, x2, x3];
for k=1:30
y1 = (1/9)*(-x2-x3+ 10);
y2 = (1/10)*(-2*x1 -3*x3 +19);
y3 = (1/11)*(-3*x1 -4*x2);
x1 = y1; x2 = y2; x3 = y3;
z = [k,x1,x2,x3];
end
fprintf('Number of Iterations: %d \n', k);
fprintf('x1: %f \n', x1);
fprintf('x2: %f \n', x2);
fprintf('x3: %f \n', x3);
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Linear Algebra 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!