clear all

% Analyzed data from Lau et al., J. Food. Eng., 2000, 231-236 for the 
% kinetics of cooking asparagus.
%
% Executes properly on MATLAB version 9.4.0.813654 (R2018a).
% Executes poorly on OCTAVE version 4.2.1.
% Joshua C. Vaughan 5/14/2020

T0 = 273.15;
T = T0 + [70 80 90 98];
k_base = [0.0034 0.0104 0.0271 0.0618]/60; % units are per second
k_bud = [0.006 0.0191 0.0493 0.0983]/60; % units are per second

ln_k_base = log(k_base);
ln_k_bud = log(k_bud);

% Cheesy line fit for cosmetic purposes. Students--do proper curve
% fitting for your research!!
P_base = polyfit(1./T,log(k_base),1); 
T_fit_base = [325 391]; 
ln_k_fit_base = P_base(1)./T_fit_base + P_base(2);

P_bud = polyfit(1./T,log(k_bud),1); 
T_fit_bud = [326 390]; 
ln_k_fit_bud = P_bud(1)./T_fit_bud + P_bud(2);

ax_lw = 2;
pl_lw = 2;
ax_fs = 24;
la_fs = 24;
lg_fs = 20;
fontname = 'Arial';
markersize = 24;

% ln(k) for y-values then plotted linearly (annoying, but more common)
figure(1); clf
plot(1./T,log(k_base),'k.','markersize',markersize); hold on
plot(1./T,log(k_bud),'.','markersize',markersize,'color',0.7*[1 1 1])
plot(1./T_fit_base,ln_k_fit_base,'k--','linewidth',pl_lw);
plot(1./T_fit_bud,ln_k_fit_bud,'--','linewidth',pl_lw,'color',0.7*[1 1 1]); 
hold off;
xlabel('1/{\itT} (K^{-1})','fontsize',la_fs)
ylabel('ln({\itk})   [{\itk} is in 1/s]','fontsize',la_fs)
set(gca,'fontsize',la_fs)
set(gca,'linewidth',ax_lw)
set(gca,'tickdir','out')
set(gcf,'color',[1 1 1])
tv = linspace(0.0026,0.003,3);
set(gca,'xtick',tv);
set(gca, 'XTickLabel', {'0.0026','0.0028','0.003'}); % gah
set(gca,'fontname',fontname)
xlim(1e-3*[2.59999 3.00001])
ylim([-10.0 -5])
set(gca,'fontname',fontname)
h = legend('base','bud');
set(h,'box','off')
set(h,'fontsize',lg_fs)
set(gca,'LooseInset',get(gca,'TightInset'));
