
Trying to calculate the temperature from the equilibrium heat equation
3 views (last 30 days)
Show older comments
Hello everyone,
I am trying to calculate the temperature from the equation :

The state of each parameter:
m = const.
= const.n=const
T = variable/vector (length = n)
How will you find the vector T?
Thanks !!!!
0 Comments
Accepted Answer
Sam Chak
on 11 Jun 2022
Edited: Sam Chak
on 12 Jun 2022
Hi @tom shneor
Edit: This is a little difficult for me to imagine since the values of the parameters are not provided. assuming that m, Cp, Qemit are all ones, create and save the odefcn.m function m-file:
function dTdt = odefcn(t, T, Qtot)
dTdt = (- 1*T^4 + Qtot)/(1*1);
end
Run at the Command Window to create the parameters needed for the ODE solver
Qtot = 1:5;
Tfinal = 10; % final simulation time
Ts = Tfinal/length(Qtot); % uniform time interval
T0 = 0; % initial Temperature value
Create a for loop to pass the value of Qtot at certain time intervals for ode45 to solve and plot T vs. t continuously at each time interval.
for k = 1:length(Qtot)
tspan = [Ts*(k-1) Ts*k];
[t, T] = ode45(@(t, T) odefcn(t, T, Qtot(k)), tspan, T0);
T0 = T(end); % last value of T assigned as new initial value for next interval
plot(t, T, 'linewidth', 1.5, 'b-')
hold on % hold current figure to continue plotting for the next interval
end
hold off
Display axes grid lines and add axis labels for informative reasons.
grid on
xlabel('t', 'fontsize', 14)
ylabel('T', 'fontsize', 14)

9 Comments
Sam Chak
on 12 Jun 2022
Hi @tom shneor
Since you are hesitate to provide at least some sample values, I have edited my Answer and tried to make the code as informative as possible. But that is not the way I normally run simulation due to the lack of the time-dependent data information about Qtot. Anyway, hope it helps.
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
