function Activity_11_2a
% MATLAB solution to Activity 11.2a of "A First Course on Kinetics and
% Reaction Engineering."
%
% Constants
V = 10; % L
VFR = 20.2; % L/min
V0 = 0; % volume percent
Vf = 0.99; % volume percent
t_bar = V/VFR; % equation (6)

% Experimental data from the table
t = [0
0.02
0.05
0.12
0.15
0.18
0.23
0.28
0.35
0.4
0.48
0.55
0.63
0.72
0.8
0.88
1
1.08
1.18
1.32
1.45
1.59
1.82
1.99
2.1
2.25
2.49];

Vt = [0
0.0565
0.0844
0.1971
0.2415
0.3209
0.3777
0.4505
0.4818
0.5488
0.6381
0.6544
0.7224
0.7613
0.777
0.8446
0.8349
0.8897
0.8999
0.9379
0.9283
0.9677
0.9453
0.9721
0.961
0.972
0.9649];

% Calculate F using equation (4)
F = Vt/Vf;

% Calculate F_CSTR using equation (5)
t_CSTR = linspace(t(1),t(length(t)));
F_CSTR = zeros(length(t),1);
for i = 1:length(t_CSTR)
    F_CSTR(i) =1-exp(-t_CSTR(i)/t_bar);
end


% Plot the results
figure
plot(t,F,'or',t_CSTR,F_CSTR,'k')
xlabel('Lambda')
ylabel('F(lambda)')
legend('Lab','CSTR')

end % of Activity_11_2a

