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

% Enter the data from the table and the gas constant
R = 8.3144e-3; % kJ/mol/K
t = [10; 22; 40; 54; 65; 78; 89; 103];
k = [2.63E-04; 4.78E-04; 1.52E-03; 4.18E-03; 9.07E-03; 2.14E-02;... 
    4.20E-02; 9.42E-02];

% Convert the temperatures to K and calculate the x values
T = t + 273.15;
x = 1./T;

% Calculate the y_hat values
y_hat = log(k);

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

% Calculate the activation energy and its 95% confidence limits
E = -m*R
lambda_E = R*m_u

% Calculate the pre-exponential factor and its 95% confidence limits
k0 = exp(b)
lambda_k0 = b_u*exp(b)