ODE45 for a second order differential equation
조회 수: 96 (최근 30일)
이전 댓글 표시
I have a second order differential equation : y''=(2*y)+(8*x)*(9-x); Boundary Conditions y(0)=0 , y(9)=0 Need to solve the diff eq using ode45.
I've tried watching a bunch of tutorials but I just cannot seem to figure out how the function is written as a column vector [y';y'']. I don't understand it at all and that might make this query vague too.
Hope someone can help with the code or the explanation on how to solve the above.
Thank you
댓글 수: 0
채택된 답변
Torsten
2018년 4월 23일
[x,y] = ode45(@fun,[0 9],[0 -28]);
function dy = fun(x,y)
dy = zeros(2,1);
dy(1) = y(2);
dy(2) = 2*y(1)+8*x*(9-x);
But for a boundary value problem like yours, you will have to use "bvp4c" instead of "ode45".
Best wishes
Torsten.
댓글 수: 5
추가 답변 (2개)
Stephan
2018년 4월 22일
편집: Stephan
2018년 4월 22일
Hi,
transform a n-th order ode into a system of n 1st order ode's to solve it.
Matlab documentation example: https://de.mathworks.com/help/matlab/math/solve-nonstiff-odes.html
If you read this i guess you can quickly solve your problem.
댓글 수: 2
Ebraheem Menda
2021년 6월 30일
편집: Ebraheem Menda
2021년 6월 30일
In this case you have declared the name of the function and its output both with the same name 'fun'. That is the problem it seems.
NARSIRAM GURJAR
2019년 9월 16일
C:\Users\remst\Desktop\ode45.m
save this file with different name
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!