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

% Data provided in the problem statement, in consistent units
V = 50; % mL
VFR = 5; % mL per min
CS0=[12.6 11.2 9.0 8.1 6.3 5.6 4.3 3.6 2.3 1.0]'; % mmol per L
CS0 = CS0/1000; % mmol per mL
CP=[1.01 0.98 0.92 0.90 0.83 0.79 0.71 0.65 0.52 0.29]'; % mmol per L
CP = CP/1000; % mmol per mL

% Calculate corresponding values of x and y_hat, equations (15) and (16)
x = 1./(CS0 - CP);
y_hat = V/VFR./CP;

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

% Calculate Vmax and Km and their uncertainties
Vmax = 1/b
Vmax_u = b_u/b^2
Km = m/b
Km_u = sqrt((m_u/b)^2 + (m*b_u/b^2)^2)

