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 CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by