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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!