Newton's Law of Cooling Euler's method, don't understand how it works in matlab

20 views (last 30 days)
Hello!
My professor has only given one example on Euler's method, so I'm really working from scratch here and would like guidance on starting Euler's method for this problem:
I apologize for asking a question with none of my own coding given. A starter or pseudocode for the Euler's would be immensely helpful!
You are working as a crime scene investigator and must predict the temperature of a homicide victim over a 5 hour period . You know that the room where the victim was found was at 10 ∘ C when the body was discovered.
Use Newton's law of cooling and Euler's method to compute the victim's body temperature for the 5 hour period using values of k = 0.12/hr and Δ t = 0.5 h r. Assume that the victim's body temperature at the time of death was 37 ∘ C , and that the room temperature was at a constant value of 10 ∘ C over the 5 hour period.
dT/dt = -k(T-T_a)
Newton's law of cooling says that the temperature of a body changes at a rate proportional to the difference between its temperature and that of the surrounding medium (the ambient temperature)
This is what I have so far:
for i=1:12
T(i+1,2)= T(i,2)+0.5*k*(T(i+1,1)-T_f);
end

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 17 Jan 2021
As you have tried, so sufficient Hint here
dt=0.5;
T_amb=10;
t=0:dt:5; % Check
T=zeros(1,length(t));
T(1)=37;
k=0.12;
for i=1:length(t)-1
dTdt=-k*(T(i)-T_amb);
T(i+1)= T(i)+0.5*dTdt;
end
plot(t,T);
grid on;

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!