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

% Data provided in the problem statement, in consistent units
T=600.; % K
P0A=150.; % Torr
P0B=450.; % Torr
Rgas=62.366; % Torr-L/(mol-K)
V=1; % L (basis)
t=[23.1 33.3 58.2 69.7 90.7 127.7 192.1 240.6 281.1]'; % h
f=[0.17 0.22 0.34 0.41 0.49 0.58 0.7 0.77 0.83]';

% Calculate x and y as described in the solution
nA0=P0A*V/Rgas/T;
nB0=P0B*V/Rgas/T;
nA = nA0*(1-f);
x = -t/V;
y_hat = (1.0/(nA0-nB0))*log(nA0/nB0./nA.*(nA-nA0+nB0));

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