필터 지우기
필터 지우기

Question on boundary value problem

조회 수: 1 (최근 30일)
Zeynep Toprak
Zeynep Toprak 2020년 4월 21일
댓글: Zeynep Toprak 2020년 5월 12일
how can I deal with this boundary value problem in matlab? since I try to learn matlab by myself, I could not ask it to anyone and so I cannot genrate a sound matlab code, therefore I post nothing. Ang hint, help or suggection will be really useful to learn these problem. thank you so much for your helps!

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 4월 21일
See the following code. The details can be quite involved, so here I just give an outline.
1. First you need to convert your 3rd order ODE to a system of 3 first order ODEs. See here for example: http://mathonline.wikidot.com/converting-nth-order-odes-to-systems-of-n-first-order-odes.
2. Then you need to write that system of ODEs into a function. See this example: https://www.mathworks.com/help/releases/R2020a/matlab/ref/bvp4c.html#mw_9083ab4d-6cde-4491-95b6-cd9b6313a459
3. Then you need to create the function to specify the boundary condition. See link in point 2 for detail.
4. Then create the initial guess. Also see link in point 2.
xmesh = linspace(0, 1, 100);
solInit = bvpinit(xmesh, [0; 0; 0]);
sol = bvp4c(@odeFun, @bcFun, solInit);
plot(sol.x, sol.y)
legend({'$y$', '$\dot{y}$', '$\ddot{y}$'}, ...
'FontSize', 16, ...
'Location', 'best', ...
'Interpreter', 'latex')
function dydx = odeFun(x, y) % ODE function
dydx = zeros(3,1);
dydx(1) = y(2);
dydx(2) = y(3);
dydx(3) = -2*exp(-3*y(1)) + 4*(1+x).^-3;
end
function res = bcFun(ya, yb) % boundary Condition fcn
res = [ya(1)-0;
ya(2)-0;
yb(1)-log(2)];
end
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 4월 24일
I am glad to be of help.
Zeynep Toprak
Zeynep Toprak 2020년 5월 12일
Dear Hamza, I have such a question, I did something, but I get wrong result, This question is similar to pde question. Can you take a look please? I like your solution, I understand perfectly :) my question is here.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Function Creation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by