% MATLAB file used in the solution of Example 14.1 of 
% "A First Course on Kinetics and Reaction Engineering."

% Data provided in the problem statement, in consistent units
wtPctNH3 = [0.8; 0.6; 0.41; 0.2; 0.016];
r_init = [0.025; 0.02; 0.01; 0.002; 0.00002]; % mol/min/L

% Calculate x and y using equations 7 and 8 from the solution

x = log(wtPctNH3);
y_hat = log(r_init);

% Use the MATLAB script file "FitLinmbSR.m" from "A First Course on
% Kinetics and Reaction Engineering" to fit a straight to the data.
FitLinmbSR

% In this case, the desired parameter, alpha, is equal to the slope so
alpha = m
alpha_u = m_u