disp ('                       Welcome')
disp (' ')
disp ('      This is the general program for Solving multiple equations with several unknowns')
disp (' ')
disp ('       This program have beean writen by Ali Ashouri')
disp (' ')
disp (' ')
disp ('     choose your used method:')
disp (' ')
disp ('      Gauss')
disp ('      Gauss - Seidal')
disp ('      Iverse Matrix')
disp (' ')
R=char(input('   which one method do you want to use and insert it as char? '));
switch R
    case 'Gauss'
        disp (' ')
        disp (' ')
        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
    case 'Gauss - Seidal'
        disp (' ')
        disp (' ')
        disp ('                This is the code of Gauss - Seidal  method.Is writen by Ali Ashouri')
        disp (' ')
disp (' ')
n=input('   enter (n) the number of array of matrix (n*n)  :');
x=cell(1,n);
y=cell(1,n);
m=cell(1,n);
for i=1:n
    x(1,i)={0};
    y(1,i)={1};
    m(1,i)={0};
end;
u=input('  enter the error : ');
disp('     enter the data of matrix: from left to right then up to down ');
a=cell(n,n+1);
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
    g=cell2mat(a(i,i));
    if g==0
    else
        for j=1:n+1
            a(i,j)={(cell2mat(a(i,j))/g)};
        end;
    end;
end;
c=0;
while c<100000
    c=c+1;
    r=1;
    for l=1:n
            r=r*(abs(cell2mat(x(1,l))-cell2mat(y(1,l)))<u);
    end;
    if r==1
        break;
    end;
    for i=1:n
        g=cell2mat(a(i,n+1));
        x(1,i)={cell2mat(y(1,i))};
        for l=1:n
            m(1,l)={0};
        end;
        for j=1:n
            if i==j
            else
                q=cell2mat(m(1,i));
                o=cell2mat(a(i,j));
                k=cell2mat(y(1,j));
                m(1,i)={q+(o)*(k)};
            end;
        end;
        y(1,i)={g-cell2mat(m(1,i))};
    end;
end;
for i=1:n;
    q=cell2mat(x(1,i));
    disp(['     x_',num2str(i),'  =  ',num2str(q)]);
end;
disp(['      the number of stage is   : ',num2str(c)]);
toc
    case 'Inverse Matrix'
disp ' '
disp ' This program was written by Ali Ashouri and in this method used inverse matrix'
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);
y=cell(n,1);
x=cell(n,1);
for i=1:n
    for j=1:n
        b=input('  Input  the cofficient of variable :  ');
        a(i,j)={b};
    end;
    c=input('  Input  the data of awnser :  ');
    y(i,1)={c};
end;
tic
A=cell2mat(a);
Y=cell2mat(y);
disp ' '
disp ' '
disp '  The matrix of the cofficient of variables  :  '
disp(A);
disp '   The matrix of data of awnser  :  '
disp(Y);
I=inv(A);
disp '   The inverse matrix of the cofficient of variables  :  '
disp(I)
X=I*Y;
disp ' The matrix of the data of variables  : '
disp(X)
disp ' '
toc
    otherwise
         disp('your method is incorrect')
end;