% MATLAB template file for solving a set of non-differential equations
% of the form
%   f1(z1, z2, z3, ..., zn) = 0
%   f2(z1, z2, z3, ..., zn) = 0
%              .
%              .
%              .
%   fn(z1, z2, z3, ..., zn) = 0
%
% See Supplemental Unit S2 of "A First Course on Kinetics and Reaction
% Engineering" and/or the MATLAB documentation for additional information
% or if questions arise.
%
% Carl R. F. Lund, 4/22/13
%   last rev. 8/18/14
%
% Returned quantities
%   z (column vector) - values of z1, z2, ..., zn that satisfy the
%       equations being solved (assuming fsolve obtained a converged
%       solution)
%
% This file requires four modifications before each use; the locations
% where editing is required are indicated by the comment "% EDIT HERE"
%
function z = SolvNonDif
    % Known quantities and constants (in consistent units)
% EDIT HERE (Required modification 1 of 4) define universal and problem-specific constants here:
    
    
    % Function that evaluates the equations
    function f = evalEqns(z)
% EDIT HERE (Required modification 2 of 4):
        f = [
            % evaluate f1(z1, z2, z3, ..., zn) here
            % evaluate f2(z1, z2, z3, ..., zn) here
            % and so on through fn, one per line
        ];
    end % of internal function evalEqns
    
    % guesses for the solution
% EDIT HERE (Required modification 3 of 4):
    z_guess = [
        % insert/calculate guess for z(1) here
        % insert/calculate guess for z(2) here
        % and so on, one z(i) per line
    ];

    % Solve the set of algebraic equations
    z = fsolve(@evalEqns, z_guess);
    display('The solver found the following values for the unknowns:');
    z
    display('The corresponding values of the functions being solved are as follows:');
    f = evalEqns(z)
    
% EDIT HERE (Required modification 4 of 4):
    % Enter code to calculate any other desired quantities using the 
    % results contained in z. (Alternatively, z will be returned when this
    % template file terminates; other quantities can then be calculated
    % at the MATLAB command prompt using the returned values
	
end % of SolvNonDif.m