Closed form solution of a system of nonlinear differential equations

1 次查看(过去 30 天)
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 个评论
Aleem Andrew
Aleem Andrew 2020-2-5
编辑:Aleem Andrew 2020-2-5
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 2020-2-5
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.

请先登录,再进行评论。

回答(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