%%
%% .... Fill components to en array
%%
A = char('NH3', 'O2', 'NO', 'N2O', 'N2', 'H2O');
%%  N   H   O
B =[
    1   3   0;   %% NH3 
    0   0   2;   %% O2
    1   0   1;   %% NO
    0   2   1;   %% N2O
    2   0   0;   %% N2
    0   2   1];  %% H2O
Y = [
     %NH3 02  NO  N2O  N2  H2O
     -4  -5   4   0    0     6;
     -2  -2   0   1    0     3;
     -4  -3   0   0    2     6];
%% - Look for B and Y matrix dimesion (ne, nc , nc)
[nr,nc] = size(Y);
[tr,ne] = size(B);

%% .... Check stoichiometry
result = chckstoi(ne, nc, nr, B, Y);

%% - Display rank of Y matrix
nir = rank(Y);
fprintf('The number of linearly independent reactions = %i \n',nir);

%% - Display all reactions
fprintf('System of (all) reactions \n');
printreac(nr, nc, Y, A, result)

%% - Test LU decomposition of stoichiometric matrix
[L,U,p]=lu(Y);
%% .... Re-Check stoichiometry, UpperTriag.
[nr,nc] = size(U);
result = chckstoi(ne, nc, nr, B, U);
fprintf('System of independent reactions \n');
printreac(nr, nc, U, A, result)
