ODE45 Solution for a coupled equation
显示 更早的评论
Hi, I have a coupled differential eqaution for a decay model. I have tried to solve the problem with ODE45 (code given below). The solution of this eqaution S and T should follow (S+T) ≤ (S0+T0) at any point of tspan. Though I am not getting a solution like that. Please let me know why and how can fix this. Thanks.
function ODEDecayModel()
clear all, close all, clc
function dotn = Mat (tspan,n)
k_rs = 1.07e-02;
k_ISC = 1.33e-02;
k_RISC = 1.13e-03;
k_nT = 3.53e-4;
dotn = zeros(2,1);
dotn(1) = -k_rs*n(1)-k_ISC*n(1)+k_RISC*n(2);
dotn(2) = -k_RISC*n(2)+k_ISC*n(1)-k_nT*n(2);
end
tspan = 00:0.1:1800;
S0 = 5.80e18; % S at 0
T0 = 0.1;% T at 0
IC = [S0 T0];%intial condition
[t,Values] = ode45(@Mat,tspan,IC);
S = Values(:,1)
T = Values(:,2)
figure(1)
plot(t,S,'b')
hold on
plot(t,T,'r')
set(gca,'xscale','log')
end
2 个评论
Bjorn Gustavsson
2019-9-25
What purpose does your clear all, close all clc serve? Inside a function taking no input arguments...
Monirul Hasan
2019-9-25
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Programming 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!