ode45 returns a vector of length 0

3 views (last 30 days)
Talha
Talha on 31 Jan 2023
Commented: Talha on 31 Jan 2023
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

Accepted Answer

Askic V
Askic V on 31 Jan 2023
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 Comment
Talha
Talha on 31 Jan 2023
Yes, you are right. Alfa being too big escaped my attention. Thank you very much.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!