Solving ODE's with time-dependent variation in inputs using ode45
显示 更早的评论
Hi guys,
Needed help in solving these ODE's for a time-dependent change in the variable T(5,1)
dT(4,1) = 0;
dT(1,1) = 2*(mdw*Cpw*(T(4)-T(1)) - hw*Aw*(((T(4)+T(1))/2) - T(3)))/(Vw*rhow*Cpw) - dT(4,1);
dT(2,1) = 2*(mdg*Cpg*(T(5) - T(2)) - hg*Ag*(((T(5) + T(2))/2) - T(3)))/(Vg*rhog*Cpg) - dT(5,1);
dT(3,1) = (hw*Aw*((T(1) + T(4))/2) + hg*Ag*((T(2) + T(5))/2) - (hw*Aw + hg*Ag)*T(3))/(mhx*Cphx);
The variable must take these values for a time span [0:1:100],
Tglin = [-6 -6.05000000000000 -6.10000000000000 -6.15000000000000 -6.20000000000000 -6.25000000000000 -6.30000000000000 -6.35000000000000 -6.40000000000000 -6.45000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.50000000000000 -6.55000000000000 -6.60000000000000 -6.65000000000000 -6.70000000000000 -6.75000000000000 -6.80000000000000 -6.85000000000000 -6.90000000000000 -6.95000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.00000000000000 -7.05000000000000 -7.10000000000000 -7.15000000000000 -7.20000000000000 -7.25000000000000 -7.30000000000000 -7.35000000000000 -7.40000000000000 -7.45000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.50000000000000 -7.54999999999999 -7.59999999999999 -7.64999999999999 -7.69999999999999 -7.74999999999999 -7.79999999999999 -7.84999999999999 -7.89999999999999 -7.94999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -7.99999999999999 -8.04999999999999 -8.09999999999999 -8.15000000000000 -8.20000000000000 -8.25000000000000 -8.30000000000000 -8.35000000000000 -8.40000000000000 -8.45000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000 -8.50000000000000];
where, Tglin = T(5,1).
Would it also be possible to then include dT(5,1) as the difference of two consecutive T(5,1) in the equations? Also, ode45 was just my first preference, but I'm also open to any other solver your think would better serve this problem.
Would appreciate all the help. Thanks!
回答(1 个)
xiaoshu liu
2020-5-15
0 个投票
I remember Matlab staff replying to another post that ODE can't take a varying input. The work around is to use interp1.
You'd have to generate a discrete set of points for your input and based on the time step, the input would be interpolated linearly.
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!