%
%   REACTION_EQNS_0.M   Example of Balances for Chemical Reaction Equations
%
%   This file has the Matlab code used with the Reaction Stoichiometry Application
%   that illustrate how to set up and solve the linear equations needed to determine
%   the stoichiometric coefficients for balancing chemical reaction equations.  See
%   the reaction_eqns.pdf file for more details...
%
%   File prepared by J. R. White, UMass-Lowell  (last update:  Nov. 2017)
%

      clear all,   close all
%
%   find coeffs for Ex. 1 with a1 = 1
      A = [-7 0 1 0;0 -2 2 1;-16 0 0 2;1 0 0 0];
      b = [0 0 0 1]';
      a = A\b
%
%   find coeffs for Ex. 2 with a1 = 1
      A = [ 0 0 -1 1 0 0; 0 -1 -3 1 4 4; 0 -2 -1 0 3 2;
           -2 0  0 0 1 0;-3  0  0 0 0 1; 1  0  0 0 0 0];
      b = [0 0 0 0 0 1]';
      a = A\b
%
%   find coeffs for Ex. 2 with a1 = 3
      b = [0 0 0 0 0 3]';
      a = A\b
%
%  end of problem