Gauss-Siedel Method

1 回表示 (過去 30 日間)
cee878
cee878 2016 年 3 月 18 日
コメント済み: Geoff Hayes 2016 年 3 月 19 日
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 Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by