
clear				% Clear previous definitions
figure(1)           % Assign figure number
clf                 % Clear previous figures
hold off            % Start with fresh graph

mytitle = 'Body Temperature'; 	% Title
xlab = '$t$'; 		% X-label
ylab = '$T(t)$'; 		% Y-label

f = @(k) 22+8*exp(-k)-28;    % Function for finding heat coefficient
k = fzero(f,0.3);            % Find the heat coefficient
ft = @(t) 22+8*exp(-k*t)-37; % Function for finding the time of death
td = fzero(ft,-5);           % Find the time of death

[t1,y1] = ode23(@murder,[0,td],30); % Simulate the heat equation
[t2,y2] = ode23(@murder,[0,12],30); % Simulate the heat equation

plot(t1,y1,'k-','LineWidth',1.5);  % Plot from death to t = 0
hold on                            % Plots Multiple graphs
plot(t2,y2,'k-','LineWidth',1.5);  % Plot from t = 0 to 12
plot([-9,td],[37,37],'r-','LineWidth',1.5);  % Plot from t = -9 to td
plot([-9,12],[22,22],'b:','LineWidth',1.5);  % Plot room temperature
plot([td,td],[20,40],'k:','LineWidth',1.5);   % Plot time of murder
grid                                % Adds Gridlines
text(-2.7,28,'Time of death, $t_d$','rot',90,'FontSize',14,...
    'FontName','Times New Roman','interpreter','latex');
text(-4.8,22.6,'Room Temperature','color','blue','FontSize',14,...
    'FontName','Times New Roman');
xlim([-9 12]);    % Defines limits of graph
ylim([20 40]);   % Defines limits of graph

fontlabs = 'Times New Roman';   % Font type used in labels
xlabel(xlab,'FontSize',14,'FontName',fontlabs,'interpreter','latex');  
        % x-Label size and font
ylabel(ylab,'FontSize',14,'FontName',fontlabs,'interpreter','latex');  
        % y-Label size and font
title(mytitle,'FontSize',16,'FontName','Times New Roman','interpreter','latex'); 
        % Title size/font
set(gca,'FontSize',12);         % Axis tick font size

print -depsc body_temp.eps		% Create figure as EPS file
%print -djpeg body_temp.jpg		% Create figure as JPEG file

