Simple relaxation method Matlab
Mostrar comentarios más antiguos
Hi.
I want to solve an ecuation system using the simple relaxation method.
I wrote the code using an exemple but the result is wrong. ( Or null? )
A=[ 67 -8 -3 78; -8 65 12 12 ; -3 12 64 -17; 78 12 -17 61];
b=[4; 6 ; 8 ;10];
n=length (b);
x=zeros (n,1) ;
r=A*x-b;
while norm (r, inf) > (10^ (-10) )
p=zeros (n,1);
[c, j]=max(abs (r) );
p ( j) =1;
t= ( -r (j) ) / A (j,j) ;
x=x+t*p;
r=A*x-b;
end
x
i
This is what I have managed to write and the result is NaN, NaN, NaN, Inf.
Is there anything I'm doing wrong? I apologise if this seems like a silly question. I'm just new into it and trying to discover how to solve it.
Thank you! I have tried both r2009a and the online version.
2 comentarios
Torsten
el 9 de Feb. de 2023
Never seen this iteration scheme. Does it have a name ? Can you give a link where it is described ?
Rolland-Luigi Eva
el 9 de Feb. de 2023
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Operating on Diagonal Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!