Using ODE 45 coupled ODEs

1 次查看(过去 30 天)
Hi!
I am supposed to solve these two linear ODEs
k = 0.0440;
C_A0 = 0.3045;
epsilon = 2;
alpha = 0.001;
F_A0 = 2.5;
rho = 0.001;
ode1 = diff(y) == -(alpha/2*y)*(1+epsilon*X)*rho;
ode2 = diff(X) == k*C_A0*(1-X)/(F_A0*1+epsilon*X)*y*rho;
I cant figure out how to use ode45 but i have tried something like this by using some other answers which i dont understand..
function dz = myode2(v,z)
syms v z
alpha = 0.001;
C0 = 0.3;
esp = 2;
k = 0.044;
f0 = 2.5;
dz = zeros(2,1);
dz(1) = k*C0/f0*(1-z(1)).*z(2)./(1-esp*z(1));
dz(2) = -alpha*(1+esp*z(1))./(2*z(2));
ode45(@myode2,[0 500],[0 1])
end
This does not work tho..
Anyone knows how to solve this by ode45?

采纳的回答

Star Strider
Star Strider 2019-10-23
Start with what you already have:
syms X(t) y(t) Y
k = 0.0440;
C_A0 = 0.3045;
epsilon = 2;
alpha = 0.001;
F_A0 = 2.5;
rho = 0.001;
ode1 = diff(y) == -(alpha/2*y)*(1+epsilon*X)*rho;
ode2 = diff(X) == k*C_A0*(1-X)/(F_A0*1+epsilon*X)*y*rho;
then use odeToVectorField and matlabFunction (linked to in that doeumentation) to create your ODE anonymous function.
This appears to be a homework assignment, so I leave the rest to you.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by