Monday 2 September 2013

Jacobi Method Code 2


clc
clear all
x=[];
y=[];
z=[];
x(1)=0;
y(1)=0;
z(1)=0;
tol = 0.001;
tx=1 , ty=2 , tz=1;
i=2;
while (1)
    x(i)= (1/8)*(20+(3*y(i-1))+*z(i-1));
    y(i)= (1/11)*(33-4*x(i-1))+(z(i-1));
    z(i)= (1/12)*(35-(6*x(i-1))-(3*y(i-1)));
    j=i-1;
    while (j>=1)
        tx=x(i)-x(j)
        ty=y(i)-y(j)
        tz=z(i)-z(j)
        if tx<=tol && ty<tol && tz<tol
            temp=1;
            break;
        end
        if temp==1
            break;
        end
    end
end

No comments:

Post a Comment