ode45 returns a vector of length 0

3 次查看(过去 30 天)
Hello everyone,
I am trying to solve a DE with ode45 however, ode45 returns a vector of length 0. Thanks in advance.
%% Clean the Workspace
clc
clear all
%% Variables
Vceo = 102.687; % m3
Cv = 1.48; % kj/kg.C
deltaHcond = 2220; % kj/kg
mCond = 50; % kg/sec
mS = 77.413098; % kg/sec
R = 0.082057338; % atm.l/mol.K
MW = 18; % kg/kmol
cpS = 1.87; % kj/kg.C
t0 = 115; % Initial temp
t_interval = [0 50]; % Time interval
IC = [t0]; % Initial Conditions
alfa = (cpS*mS-deltaHcond*mCond)/(Cv*(mS-mCond));
%% Solve the DE
[t,Tsol] = ode45(@(t,T) cfunc(t,T) , t_interval , IC);
%% Plotting
plot(t,Tsol)
function dTdt = cfunc(t,T)
global alfa
dTdt = (T*alfa-T)/t ;
end

采纳的回答

Askic V
Askic V 2023-1-31
I see few problems. First have a look at this suggestion:
Coefficient alfa is huge, so change in tempearture is very fast, therefore I use damping coeff 0.0001. I have changed the interval also.
Vceo = 102.687; % m3
Cv = 1.48; % kj/kg.C
deltaHcond = 2220; % kj/kg
mCond = 50; % kg/sec
mS = 77.413098; % kg/sec
R = 0.082057338; % atm.l/mol.K
MW = 18; % kg/kmol
cpS = 1.87; % kj/kg.C
t0 = 115; % Initial temp
t_interval = [0.1 2]; % Time interval--change
IC = t0; % Initial Conditions
alfa = 0.0001* (cpS*mS-deltaHcond*mCond)/(Cv*(mS-mCond));% alfa is too big
% Solve the DE
[t,Tsol] = ode45(@(t,T) cfunc(t,T, alfa) , t_interval , IC);
% Plotting
plot(t,Tsol, '-o')
function dTdt = cfunc(t,T, alfa)
dTdt = (T*alfa-T)/t ;
end
  1 个评论
Talha
Talha 2023-1-31
Yes, you are right. Alfa being too big escaped my attention. Thank you very much.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by