Implementing a code from Berkley Madonna into Matlab
Mostra commenti meno recenti
I am trying to implement a code from Berkley Madonna into Matlab. I want to carry out a simulation and produce the results graphically by using ode solvers directly. Here is this Berkley Madonna code I am trying to incorporate:
METHOD RK4
STARTTIME = 0
STOPTIME = 300 {minutes}
DT = 0.02
Km = 0.0184
Vg = 2.4
Vl = 1.08
Vc = 11.56
Vm = 25.76
FL = 1.35
Fm = 0.95
D=0.2
{D is a function of 5g ethanol dose and 100 kg body weight}
ks = -0.049*(D) + 0.0545
INIT Vs = 1
d/dt(Vs) = -ks*Vs
INIT Cg = 0
INIT Cl = 0
INIT Cc = 0
INIT Cm = 0
Vmax = 0.1012
d/dt(Cg) =((((2/3)*FL)*(Cc - Cg) +(ks*Vs))/Vg)
rel = (Vmax*Cl)/(Km + Cl)
d/dt(Cl) = ((FL*(0.33*Cc + .66*Cg - Cl) - rel)/Vl)
d/dt(Cc) = ((-FL*(Cc - Cl) - Fm*(Cc - Cm))/Vc)
d/dt(Cm) = (Fm*(Cc-Cm)/Vm)
1 Commento
William Rose
il 8 Apr 2021
@Justin Lee, I'm not familiar with Berkley Madonna and I bet most other readers aren;t. If you post the equations you are trying to simulate, instead of a bunch of code that people cannot parse, you will be more likely to get a helpful reply.
You can format your equations by clicking the capital sigma icon about the message window. The equation editing window which pops up uses Latex formatting. I always thought Latex was too complicated for me, but I finally gave it a try a week ago, and it is easier than I expected. Every time I want to do something, I do a google search: "Latex for subscript", "Latex for a fraction", etc. Example (I think this is one of your differential equations):

I recommend reading Intro to solving ODEs in Matlab and the Matlab help for ode45(). One of the things you will learn is that you don't need DT=0.02 (which your code defines) because ode45() is a 4th order Runge Kutta routine with adaptive stepsize - the routine figures out and adjusts the step size as it goes.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Ordinary Differential Equations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

