MATLAB Ode45 Code Being Strange

1 vue (au cours des 30 derniers jours)
Anneliese Fensch
Anneliese Fensch le 25 Nov 2020
Commenté : Walter Roberson le 25 Nov 2020
Hello!
My professors and I are trying to figure out a bug in our code for cooking a 5 foot in diameter donut. We are supposed to find how long it takes to get the oil for the donut to heat up to the correct temperature. Below is the code that we have right now.
Function file donut
function dDdt = donut(t,D)
% This script makes the ode45 function for cooking the five foot donut
Q = 15000; % 50000 btu/hr = 15000 W
N = 4; % Number of burners
m_o = 2553; % Mass of oil in kilograms
c_o = 1.9; % Specific heat in kilojoules per kilograms
T_init = 295;
T_a = 295; % Initial temp outside in Kelvin
h_s = 25; % Heat transfer from surface in work per meters squared kilometers
A_s = 4.55; % Area of the top of the surface in oil in meters squared
L_d = 0.0254; % Thickness of dumpster wall in meters
k_d = 40; % Thermal conductivity of steel in watts per meters Kelvin
A_d = 5.20; % External surface area of the dumpster in meters squared
h_d = 25; % Heat transfer from donut to surface in work per meters squared kilometers
dDdt = (N*Q/(m_o*c_o))-(T_init-T_a)*(h_s*A_s+1/(L_d/(k_d*A_d)+1/(h_d*A_d)));
end
Code Script to solve the ode45
T_init = 295; % Initial temperature of oil
tspan = [0 86400]; % Time span for oil to heat
[t, D] = ode45(@donut, tspan, T_init);
plot(t,D)
set(gca, 'FontSize', 16);
xlabel('Time (in Seconds)', 'FontSize', 18);
ylabel('Temperature of Oil in C', 'FontSize', 18);
title('Donut Cooking', 'FontSize', 20);
The time span is 24 hours in seconds.
This is the graph we are getting
This is the graph that we are supposed to get, based off of a tutorial that shows what the results should be.
Thank you for the help!
  3 commentaires
Anneliese Fensch
Anneliese Fensch le 25 Nov 2020
What can I do to fix this?
Walter Roberson
Walter Roberson le 25 Nov 2020
dDdt = (N*Q/(m_o*c_o))-(T_init-T_a)*(h_s*A_s+1/(L_d/(k_d*A_d)+1/(h_d*A_d)));
your T_init and T_a are the same. Subtract gives 0. Multiply by anything gives 0 provided it is finite.
So your formula is just
dDdt = (N*Q/(m_o*c_o))
which does not involve t or D and so is constant, so you are going to get a straight line.
Besides that second part of the formula does not involve t or D either.
You need to review the formula. It will have time or the boundary value in it somewhere.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by