Finding a specific ode solution
Show older comments
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 Comments
Alan Stevens
on 10 Mar 2021
You pass two parameters to your odefcn, but have it return three!
What are the mathematical equations you are trying to solve?
Kara Scully
on 10 Mar 2021
Alan Stevens
on 10 Mar 2021
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?
Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!