Matlab - metodo iterativo de jacobi

 
Vista:
Imágen de perfil de daniel

metodo iterativo de jacobi

Publicado por daniel (2 intervenciones) el 14/06/2015 19:09:46
he intentado hacer el código matlab del algoritmo del método iterativo de Jacobi del libro de Burden <<análisis númerico>>
CUANDO HAGO CORRER EL PROGRMA ME SALE

Error using -
Matrix dimensions must agree.

Error in Untitled2 (line 19)
norma=norm(x-X0);
Y NO SE POR QUE si alguien me puede ayudar por favor
gracias de antemabno


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
%programa del metodo iterativo de jacobi 2
clear all;
n=input('ingrese el orden de la matriz: \n');
A=input('ingrese la amtriz A= \n');
b=input('ingrese el vector de terminos indepemndientes: \n');
X0=input('ingrese la aproximacion inicial X0= \n');
tol=input('ingrese la tolerancia tol= \n');
N=input('ingrese el numero de iteraciones N= \n');
k=1;
while k<=N
    for i=1:n
        suma1=0;
        for j=1:n
            if i~=j
                suma1=suma1+A(i,j)*X0(j);
            end
            x(i)=(b(i)-suma1)/A(i,i);
        end
        norma=norm(x-X0);
        if norma<tol
           fprintf('%10.6f\n',x(i));
           fprintf('prosedimiento terminado exitosamente')
        end
    end
    k=k+1;
    for i=1:n
        X0(i)=x(i);
    end
end
    if k>N
        break
    end
disp('numero de iteraciones excedido');
fprintf('procedimiento terminado sin exito');
fprintf('\nTABLA:\n\t   norma   x(i)\n\n  ');
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder