Closed form solution of a system of nonlinear differential equations

1 回表示 (過去 30 日間)
Aleem Andrew
Aleem Andrew 2020 年 2 月 4 日
コメント済み: Walter Roberson 2020 年 2 月 5 日
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 Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by