Borrar filtros
Borrar filtros

Newton's Law of Cooling - ode45

14 visualizaciones (últimos 30 días)
JB
JB el 21 de Jul. de 2018
Comentada: Rakib-Al- Hasan el 31 de Ag. de 2021
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 comentarios
JB
JB el 21 de Jul. de 2018
Interesting. How would it look if I didn’t integrate and needed to use ode45?
Rakib-Al- Hasan
Rakib-Al- Hasan el 31 de Ag. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Star Strider
Star Strider el 21 de Jul. de 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 comentarios
JB
JB el 22 de Jul. de 2018
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 el 22 de Jul. de 2018
As always, my pleasure!
With MATLAB, scientific computing is extremely efficient. The more you work with it, the more you will like it.

Iniciar sesión para comentar.

Más respuestas (1)

Aj Barayang
Aj Barayang el 20 de En. de 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.

Categorías

Más información sobre Programming en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by