Newton's Law of Cooling - ode45

49 ビュー (過去 30 日間)
JB
JB 2018 年 7 月 21 日
コメント済み: Rakib-Al- Hasan 2021 年 8 月 31 日
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 件のコメント
JB
JB 2018 年 7 月 21 日
Interesting. How would it look if I didn’t integrate and needed to use ode45?
Rakib-Al- Hasan
Rakib-Al- Hasan 2021 年 8 月 31 日
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.

サインインしてコメントする。

採用された回答

Star Strider
Star Strider 2018 年 7 月 21 日
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 件のコメント
JB
JB 2018 年 7 月 22 日
Thank for your help and professionalism. This will certainly help me understand Newton's Law of Cooling through the lens of Matlab functionality. I am beginning to really like Matlab.
Star Strider
Star Strider 2018 年 7 月 22 日
As always, my pleasure!
With MATLAB, scientific computing is extremely efficient. The more you work with it, the more you will like it.

サインインしてコメントする。

その他の回答 (1 件)

Aj Barayang
Aj Barayang 2021 年 1 月 20 日
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.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by