Finding a specific ode solution
显示 更早的评论
Hello! I am trying to solve an ode given starting data and some of the final data, how would I get it to display the time and the y matrix given that y(1) final should be 1e6?
clc; clear;
t = linspace(0,1e7);
C0 = [1e-9,2e6]; %initial concentrations, Z close to zero
%y(1) = Z y(2) = H
%want the time and other concentrations when H=1e6
[t,y] = ode45(@odefcn,t,C0);
function dydt = odefcn(t,y) %y=Cj
kj = [5e-7,4.7e-7];
r = [kj(1)*y(1)*y(2);kj(2)*y(1)*y(2)];
stoictransposed = [1 -1 ;
-1 0 ;
0 1 ];
Rj = stoictransposed*r;
dydt=[Rj];
end
3 个评论
Alan Stevens
2021-3-10
You pass two parameters to your odefcn, but have it return three!
What are the mathematical equations you are trying to solve?
Kara Scully
2021-3-10
Alan Stevens
2021-3-10
If you make the first term of stoictransposed 1.44 instead of 1, then y(1) ends up at 10^6. However, this is quite arbitrary. Can you explain more about the underlying system that is being modelled?
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Ordinary Differential Equations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!