필터 지우기
필터 지우기

2nd order non linear ODE

조회 수: 1 (최근 30일)
Ahsan Mujtaba
Ahsan Mujtaba 2021년 3월 16일
댓글: Star Strider 2021년 3월 25일
I cannot figure out how to solve the folowing non linear eigen value ODE numerically on MATLAB.
I know the value of the second term, g as well. My boundary conditions are and . I know how to solve it by hand but MATLAB is a different story for me. Please help out.
  댓글 수: 2
KSSV
KSSV 2021년 3월 17일
Have a look on ode45
Ahsan Mujtaba
Ahsan Mujtaba 2021년 3월 18일
Do I have to convert it into system of 2 first order equation?

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

답변 (1개)

Star Strider
Star Strider 2021년 3월 18일
Do I have to convert it into system of 2 first order equation?
Yes.
The Symbolic Math Toolbox can make that easier. Use the odeToVectorField and matlabFunction functions to create it as an anonymous function.
Also, since this is a boundary value problem, bvp4c or similar functions may be most appropriate. (I have no idea what ‘E’ and ω are, however using this approach and using random values for those and guessing 9.81 for ‘g’, I got it to work with bvp4c.)
I would post my solution, however I would not want to deprive you of the experience of discovering how to do all this for yourself.
  댓글 수: 15
Ahsan Mujtaba
Ahsan Mujtaba 2021년 3월 25일
function dydx = bvpfcn(x,y)
dydx = zeros(2,1);
dydx = [y(2)
(2*0.4878-(((sin(sqrt(10))*x)^2)/10))*y(1)];
end
function res = bcfcn(ya,yb)
res = [ya(1)
yb(1)];
end
function g = guess(x)
g = [sin(x)
4*cos(x)];
end
xmesh = linspace(-pi/2,pi/2,100);
solinit = bvpinit(xmesh, @guess);
sol = bvp4c(@bvpfcn, @bcfcn, solinit);
plot(sol.x, sol.y)
Can you please see this code this time I have carefuly coded the BCs but still my plots are not coming right. I am a beginner I would appreciate any leads. Thanks
Star Strider
Star Strider 2021년 3월 25일
I am not certain what it is supposed to look like, or if my plot is correct. (It would appear to be correct, however I am not certain it is.)
I used a different ‘guess’, and when I use the same in your code, I get essentially the same result I got in mine, although your ‘dydx’ is different from the function I used, that being the result of the matlabFunction call in my code. I also used only 25 points in ‘xmesh’, and that made for a smoother plotted result.
UPDATE — I did not previously realise it, however Mathieu’s equation is actually in the MATLAB documentation. (I just now discovered that in an Interweb search.) See Solve BVP with Unknown Parameter for details. It woulld appear that my result is correct, given that the parameters may not be the same (I have not checked them, since it is late here, and the end of my day.).
I find that comforting!

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

카테고리

Help CenterFile Exchange에서 Boundary Value Problems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by