How to use Runge-Kutta 4th order methode in MATLAB to solve a system of differential equations ?

3 views (last 30 days)
Hello
how can i build a Runge-Kutta 4th order code in matlab to solve a system of 10 first order differential equations ?
(I don't want to use other solvers like ode45, ode15s ..., but i want to create my own code).
this is my system
THANKS A LOT
%initial conditions
V0_w = 6.2518e+06;
T0 = 423;
d0_gw = 0;
n_0 = 0;
C0_1 = 0;
C0_2 = 0;
C0_3 = 0;
C0_4 = 0;
C0_5 = 0;
C0_6 = 0;
%system
dVw_dt = 753.0149737-0.00004046944557*y(1);
dT_dt = ((3.244e-7 * y(4)-67.5068*y(2)+28555.3764)/(4.18*(-3.51e-6 *(y(2))^2 +0.00201*y(2)+0.7125)*y(1)+1.8364e54))...
-((0.0001123233192*(-3.51e-6 *(y(2))^2 +0.00201*y(2)+0.7125)*(y(2)-423)*(1.8607e7 - y(1)))/...
(4.18*(-3.51e-6 *(y(2))^2 +0.00201*y(2)+0.7125)*y(1)+1.8364e54));
ddgw_dt =0;
dn_dt = 68*y(4)*(174.0520235-(1/(((2.836348e-25 *exp(-3.8487262e-10 *(-3.51e-6 *(y(2))^2 +0.00201*y(2)+0.7125)*y(1)))...
/(2.3102e-23 + 9.5062715e-34 *(-3.51e-6 *(y(2))^2 +0.00201*y(2)+0.7125)*y(1)))+1.130638075)))...
+0.01249*y(5) + 0.03167*y(6) + 11011*y(7) + 0.32035*y(8) + 1.34622*y(9) + 8.88685*y(10) + 25822;
dC_1_dt = 0.9*y(4)-0.01249*y(5);
dC_2_dt = 13.3*y(4)-0.03167*y(6);
dC_3_dt = 9.4*y(4)-0.11011*y(7);
dC_4_dt = 33.5*y(4)-0.32035*y(8);
dC_5_dt = 8.5*y(4)-1.34622*y(9);
dC_6_dt = 2.4*y(4)-8.88685*y(10);
%
F = [dVw_dt;dT_dt;ddgw_dt;dn_dt;dC_1_dt;dC_2_dt;dC_3_dt;dC_4_dt;dC_5_dt;dC_6_dt];

Answers (0)

Community Treasure Hunt

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

Start Hunting!