Gauss-Siedel Method
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
el 19 de Mzo. de 2016
Chris - please describe what the problem is. Are you observing any errors and, if so, what are they?
Respuestas (0)
Ver también
Categorías
Más información sobre Linear Algebra en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!