% Plots of Dog data (Add straight lines)
load 'dog'
t = dog(:,1); d = dog(:,2);
L3 =[0.1601,0.02078,0.003794];
A3 = vanAexp(t,L3);
a3 = A3\d
model3d = a3(1)*exp(-L3(1)*t) + a3(2)*exp(-L3(2)*t) + a3(3)*exp(-L3(3)*t);
sse3 = sum((d-model3d).^2)
lnsse3 = sum((log(d)-log(model3d)).^2)
aa3 = [8.1514,1.6396,0.6083];
modelpeel = aa3(1)*exp(-L3(1)*t) + aa3(2)*exp(-L3(2)*t) + aa3(3)*exp(-L3(3)*t);
sse3p = sum((d-modelpeel).^2)
lnsse3p = sum((log(d)-log(modelpeel)).^2)

%Plot Data and Models
tt = linspace(0,400,200);
semilogy(t,d,'ro');
hold on
semilogy(tt,aa3(1)*exp(-L3(1)*tt)+aa3(2)*exp(-L3(2)*tt)+aa3(3)*exp(-L3(3)*tt),'b-','LineWidth',1.5);
semilogy(tt,a3(1)*exp(-L3(1)*tt)+a3(2)*exp(-L3(2)*tt)+a3(3)*exp(-L3(3)*tt),'r--','LineWidth',1.5);
grid
h = legend('Data','Exp Peeling','3-Compartment','Location','northeast');
set(h,'Interpreter','latex')
ylim([0.1,10]);

% Set up fonts and labels for the Graph
fontlabs = 'Times New Roman';  
xlabel('$t$ (min)','FontSize',16,'FontName',fontlabs, ...
    'interpreter','latex');  
ylabel('$C$ (ng/ml)','FontSize',16,'FontName',fontlabs, ...
    'interpreter','latex'); 
mytitle = 'Plasma Concentration of Fentanyl';
title(mytitle,'FontSize',16,'FontName', ...
    'Times New Roman','interpreter','latex'); 
set(gca,'FontSize',16);

print -depsc fent_exls_gr.eps
