Gauss-Siedel Method

1 次查看(过去 30 天)
cee878
cee878 2016-3-18
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);
  1 个评论
Geoff Hayes
Geoff Hayes 2016-3-19
Chris - please describe what the problem is. Are you observing any errors and, if so, what are they?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Linear Algebra 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by