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

% Data provided in the problem statement, in consistent units
T=500.+273.15; % K
Rgas=62.366; % (L-mm Hg)/(mol-K0
P0=[25 73 136 186 215]'; % mm Hg
hl=[4.51 2.61 1.92 1.61 1.50]'; % h

% Calculate x and y as described in the solution
x = log(P0/Rgas/T);
y_hat = log(hl);

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

% Calculate the reaction order and its uncertainty
order = 1 - m
order_u = m_u
