Está en la página 1de 1

%Metodo de Jacobi

clear
A=[4 -3 1 -2;2 -5 -1 4;1 -2 7 1;3 -5 2 10]
b=[-7 5 22 39]
XO=zeros(1,4);
K=0;Normal=1;
fprintf(`K X(1) X(2) X(3) X(4) Norma/n)
while Norma > 0.0001
K=K+1;
fprintf(`%2d,K)
for i=1:4
suma=0;
for j=1:4
if i ~= j
suma=suma+A(i,j)*XO(j);
end
end
X(i) = (b(i)-suma)/A(i,i);
fprintf(`%10.4f,X(i))
XO=X;
if K > 25
disp(`No se alcanzo la convergencia)
break
end
end

También podría gustarte