필터 지우기
필터 지우기

Newton's Law of Cooling - ode45

조회 수: 14 (최근 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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by