Solving System of Nonlinear Differential equations
7 views (last 30 days)
Show older comments
Daniel Fröhlich
on 22 Aug 2020
Commented: Cyrus Azizzadeh
on 5 Jan 2022
I Need to solve the following system with ode45: (first order in R and second order in K)
R'(t)^2+a=b*K(t)^2*R(t)^(-1)
K''(t)+3*R(t)^2*R'(t)*K'(t)=c*R(t)^(-3)*K(t)^(-1)
with initial values:
R(0)=1
K(0)=3
K'(0)=0
I never used Matlab before, so would be great if someone could help me.
0 Comments
Accepted Answer
Alan Stevens
on 22 Aug 2020
The following structure is what you need (notice that the second order ode is turned into two first order ones);
R0 = 1;
K0 = 3;
vK0 = 0;
Y0 = [R0 K0 vK0];
tspan = [0 10]; % Replace with your desired range
[t, Y] = ode45(@rate, tspan, Y0);
R = Y(:,1);
K = Y(:,2);
plot(t,R)
% etc.
function dYdt = rate(~,Y)
a = 1; % Replace with your own value
b = 1; % Ditto
c = 1; % Ditto
R = Y(1);
K = Y(2);
vK = Y(3);
dRdt = sqrt( b*K^2/R - a );
dKdt = vK;
dvKdt = c/(R^3*K) - 3*R^2*dRdt*dKdt;
dYdt = [dRdt;
dKdt;
dvKdt];
end
2 Comments
Cyrus Azizzadeh
on 5 Jan 2022
Hello
my equations system is like below. can I solve system like this in matlab?
dy(1) = 3*y(1) *t.^3 + y(2) + sin(dy(2)) + tan(dy(1)) ;
dy(2) = y(2) - y(1) + y(2).^4 + y(2).^4 + 3*t*dy(1) + t.^3*cos(y(1));
More Answers (0)
See Also
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!