Gauss-Siedel Method

2 visualizaciones (últimos 30 días)
cee878
cee878 el 18 de Mzo. de 2016
Comentada: Geoff Hayes el 19 de Mzo. de 2016
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 comentario
Geoff Hayes
Geoff Hayes el 19 de Mzo. de 2016
Chris - please describe what the problem is. Are you observing any errors and, if so, what are they?

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by