ode45 returns a vector of length 0

조회 수: 3 (최근 30일)
Talha
Talha 2023년 1월 31일
댓글: Talha 2023년 1월 31일
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