Different answer using ODE45 and symbolic solve

I've been working through a problem using 2 different methods to solve the time required to reach 135C. One uses ode45 where I iterate through and find that its roughly 162.6 seconds but when I try a different method using symbolic int and solve I get 170 seconds. I can't figure out what's causing the different results.
tspan = [0:0.1:180]
y_0=25
[t T] = ode45(@odefun,tspan,y_0)
Temp=T(1627,1)
time=t(1627,1) % using ode45
time_2=answer_2() % using symbolic solve
function dtdT = odefun(t,T)
A=0.04;
l=0.007;
V=A*l;
h=10;
q_h=1.25*10^4;
sigma = 5.67*10^-8;
C=900;
p=2800;
e=0.80;
T_i=25;
B=(q_h - h*(T-T_i) - ( e*sigma*(T^4 - T_i^4)));
D=A/(V*C*p);
dtdT = D*B;
end
function A=answer_2()
syms t
A=0.04;
l=0.007;
V=A*l;
h=10;
q_h=1.25*10^4;
sigma = 5.67*10^-8;
C=900;
p=2800;
e=0.80;
T_i=25;
T=135;
B=(q_h - h*(T-T_i) - ( e*sigma*(T^4 - T_i^4)));
D=A/(V*C*p);
Solution = double(solve( T-T_i == (D*int(B,t,0,t)),t));
A=Solution;
end

 Réponse acceptée

Torsten
Torsten le 29 Oct 2018

0 votes

What make you think the two problem formulations are equivalent ?
Symbolically you solve an algebraic equation while numerically, you solve an ordinary differential equation.
Use "dsolve" instead of "solve" in the symbolic part.
Best wishes
Torsten.

1 commentaire

Adam Watts
Adam Watts le 29 Oct 2018
I believe the solution guide I was working through made a mistake and I solved it another method and I got the almost identical solution using ode45. Thanks for suggesting dsolve.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Produits

Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by