Closed form solution of a system of nonlinear differential equations

1 view (last 30 days)
The following code graphs the solution to a a system of nonlinear differential equations. How can I find the closed form solution to the system that expresses y as a function of x?
function dydt = odeproject(t,y,A,B)
if nargin < 3 || isempty(A)
A = 1;
end
if nargin < 4 || isempty(B)
B = 2;
end
tspan = [0 0.5];
y0 = [2 7.524];
[t,y] = ode45(@(t,y) odefcn(t,y,A,B), tspan, y0);
plot(t,y(:,1),'-o',t,y(:,2),'-.')
end
function dydt = odefcn(t,y,A,B)
dydt = zeros(2,1);
dydt(1) = A(1);
dydt(2) = B(1);
dBdt = y(2) * sqrt((y(2)*y(2)+y(1)*y(1)));
dAdt = y(1) * sqrt((y(2)*y(2)+y(1)*y(1))) -9.81;
end
  5 Comments
Aleem Andrew
Aleem Andrew on 5 Feb 2020
Edited: Aleem Andrew on 5 Feb 2020
I am not sure how to write the code for such a function. I know how to create a function that has as parameters a dependent and an independent variable but not more than two. A and B are constants but should be the first derivatives of variables I need to differentiate twice with respect to a single independent variable. The code I wrote was intended to solve the following system of nonlinear differential equations:
x''=x'*sqrt(x'^2+y'^2) y''=y'*sqrt(x'^2+y'^2)-9.81
Walter Roberson
Walter Roberson on 5 Feb 2020
You can do a change of variables to rewrite as
XP' = XP * sqrt(XP^2 +. YP^2)
YP' = YP * sqrt(XP^2 +. YP^2) - 9.81
and then run that as a system of two variables. If you need x and y you can do numeric integration such as cumtrapz. If you need a more accurate x and y you would use a system with four parameters.

Sign in to comment.

Answers (0)

Categories

Find more on Programming 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!