disp ('                This is the code of Gauss  method.Is writen by Ali Ashouri')
disp (' ')
disp (' ')
n=input('   enter (n) the number of array of matrix (n*n)  :');
disp('     enter the data of matrix: from left to right then up to down ');
a=cell(n,n+1);
x=cell(1,n);
for i=1:n
    x(1,i)={0};
end;
for i=1:n
    for j=1:n+1
        b=input('the number : ');
        a(i,j)={b};
    end;
end;
disp(a);
tic
for i=1:n-1
    for j=i+1:n
        L=cell2mat(a(i,j));
        P=cell2mat(a(j,i));
        if (abs(L)<abs(P))
            for t=1:n+1
                k=a(i,t);
                a(i,t)=a(j,t);
                a(j,t)=k;
            end;
        end;
    end;
    for j=i+1:n
        g=-cell2mat(a(j,i))/cell2mat(a(i,i));
        if g==0
        else
            for t=i:n+1
                a(j,t)={cell2mat(a(i,t))*g+cell2mat(a(j,t))};
            end;
        end;
    end;
end;
for i=1:n
    for j=1:n+1
        if abs(cell2mat(a(i,j)))<0.00009
            a(i,j)={0};
        end;
    end;
end;
for j=n:-1:1
    g=cell2mat(a(j,j));
    m=0;
    for t=j+1:+1:n
        m=m+cell2mat(a(j,t))*cell2mat(x(1,t));
    end;
    if g==0
    else
        x(1,j)={(cell2mat(a(j,n+1))-m)/g};
    end;
end;
for i=1:+1:n;
    q=cell2mat(x(1,i));
    disp(['     ',num2str(q)]);
end;
toc