Solution to nonlinear differential equation

조회 수: 7 (최근 30일)
Marcus Rosales
Marcus Rosales 2019년 10월 29일
댓글: darova 2019년 10월 31일
Hello, I am trying to solve the following differential equation, but I am running into some issues when using ODE45:
subject to the boundary conditions:
I broke this up into a system of two first order differential equations, but I am having trouble with the following aspects of the problem:
  1. How do you input initial conditions which are both given in terms of just the function (i.e. not it's derivatives)?
  2. ODE45 will not be able to go too far past |t|=10, so should I just set my bc's at this point?
Any help would be greatly appreciated or a indication of the correct direction for solution. Thanks in advance!
  댓글 수: 2
Cyrus Tirband
Cyrus Tirband 2019년 10월 29일
If you're dealing with boundary conditions rather than initial conditions, it's better to use a boundary value problem solver like bvp4c. It allows you to set the values of your function at the boundaries, like you want.
However, I'm not sure your particular equations will work. Can you double check your equation? I tried putting it in the solver but the solution is a mess and very unstable. If a is not perfectly pi/2 for t>0, it will never have a limit value.
Marcus Rosales
Marcus Rosales 2019년 10월 29일
I was uncertain too, but yes I have it correct. I would have expected a negative sign in the expoential, so maybe the actual paper has a typo. I attached a screen shot of the equation.

댓글을 달려면 로그인하십시오.

채택된 답변

darova
darova 2019년 10월 30일
Here is an attempt
function bvp4c_mathworks
solinit = bvpinit([-1 1],[0 0]); %[-inf, inf] replaces with [-1, 1]
sol = bvp4c(@myode,@mybc,solinit);
plot(sol.x, sol.y), grid on
% legend('y(t)','x(t)')
% xlabel('t')
end
function dy = myode(t,y)
dy(1,1) = y(2);
dy(2,1) = 1/2*(1-exp(2*t))*sin(y(1));
end
function res = mybc(ya,yb)
res = [ya(1)
yb(1)-pi/2];
end
  댓글 수: 2
Marcus Rosales
Marcus Rosales 2019년 10월 31일
Thanks for the reply! This works I beileve (I have plots to compare this to); just had to modify plot(...) to plot([-1,1],sol.y) to get what I wanted.
Could I ask a quick question: why did you choose the intreval [-1,1]? I would have thought I'd need a longer intreval than this to approximate the BCs, so was there a reason or was it more of an arbitrary choice?
darova
darova 2019년 10월 31일
  • why did you choose the intreval [-1,1]?
It was just a shot in the dark. I like how it looks so why not. [-10 10] doesn't work for me=(

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by