Newton's Law of Cooling - ode45
14 views (last 30 days)
Show older comments
Hello:
I am trying to write a code using a function to plot the ratio of time intervals between the following measurements:
T_o=100 →initial temperature in Celsius T_a=ambient temperature in Celsius T_1=80 →temperature in Celsius after cooling for 5 minutes T_2=65 →temperature in Celsius after cooling for 5 minutes t=5 →time left to cool M=25 →final temperature
My answer: T_a=20 degrees Celsius →temperature in the kitchen
I am trying to develop matlab code that can examine the ration R between the time intervals.
Using T(t)=80-15e^5k, I attempted to translate this into a function.
Defining the function:
function y = func5(T, k)
y = 80 - 15*exp(5k);
end
I have only been using matlab for a few weeks and any assistance would be greatly appreciated.
V/R jb
2 Comments
Rakib-Al- Hasan
on 31 Aug 2021
A person places $20,000 in a savings account which pays 5 percent interest per
annum, compounded continuously. Find
(a) the solution of the dollar balance in the account at any time
(b) the amount in the account after three years.
Accepted Answer
Star Strider
on 21 Jul 2018
I am not certain what you want to do. You already have the integrated differential equation, so ode45 is likely unnecessary here.
This would be my approach:
% % % b(1) = T_a, b(2) = k
Tfcn = @(b,t,T_0) (T_0 - b(1)).*exp(b(2).*t) + b(1);
tv = [ 0; 5; 10];
Tv = [100; 80; 65];
p = fminsearch(@(b) norm(Tv - Tfcn(b,tv,Tv(1))), [10; 1]); % Estimate Parameters
Final_T = Tfcn(p,15,Tv(1)); % Temperature @ 15 Minutes
Final_t = fzero(@(t) Tfcn(p,t,Tv(1)) - 25, 1); % Time To Reach 25°C
time = linspace(min(tv),Final_t);
Tfit = Tfcn(p,time,Tv(1));
figure
plot(tv, Tv, 'p')
hold on
plot(time, Tfit, '-r')
hold off
grid
xlabel('Time (min)')
ylabel('T (°C)')
3 Comments
Star Strider
on 22 Jul 2018
As always, my pleasure!
With MATLAB, scientific computing is extremely efficient. The more you work with it, the more you will like it.
More Answers (1)
Aj Barayang
on 20 Jan 2021
When an object with an initial temperature To is placed in a substance that has a temperature Ts, according to Newton’s law of cooling, in t minutes it will reach a temperaturuje T(t) using the formula
where k is a constant value that depends on properties of the object. For an initial temperature of 100 C and k = 0.6, graphically display the resulting temperatures from 1 to 10 minutes for two different surrounding temperatures: 50 C and 20 C. Use the plot function to plot two different lines for these surrounding temperatures.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/494514/image.png)
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!