matlab second order nonlinear ode
I want to get a non-linear derivative of the nonlinear secondary differential equation as a function of x (t) = t. I'm not sure how to use the ODE 45 function. A, b is a constant number.
Ex) a = 10b = 100 and X (Time = 0) = 10
I would appreciate it if you would let me know how to use ODE 45.
So for the first time, I'm trying to figure out a non-linear calculus equation, but I don't know if I'm doing it wrong, but when I did, I got a graph.
Maybe one thing is that one speed is displacement, but I wonder if it's true that this is not a normal foe, but it's not something that can be expressed as x (t).
Please let me know how to use the ODE 45 instructions!

 채택된 답변

James Tursa
James Tursa 2017년 9월 6일
편집: James Tursa 2017년 9월 6일

1 개 추천

Since it is a 2nd order ODE, first define a 2-element vector, let's call it y just like the examples in the ode45 doc, that matches your x stuff:
y(1) = x
y(2) = xdot
So we have defined y(1) as x, and y(2) as xdot.
Next, rewrite your ODE above, solving for the highest order derivative:
(1/a + a/b^2)*xdotdot + (1/a^2)*exp(-(1/a)*x) - 1/b^2 = 0
==>
xdotdot = (-(1/a^2)*exp(-(1/a)*x) + 1/b^2 ) / (1/a + a/b^2)
Then write down the derivatives of your y vector elements in terms of y:
d y(1) / dt = d x / dt = xdot = y(2)
d y(2) / dt = d xdot / dt = xdotdot = (-(1/a^2)*exp(-(1/a)*x) + 1/b^2 ) / (1/a + a/b^2) = (-(1/a^2)*exp(-(1/a)*y(1)) + 1/b^2 ) / (1/a + a/b^2)
Now, create a function that calculates the derivative of the 2-element y vector. E.g., suppose we create a file called yderivative.m and have the following code in it:
function dydt = yderivative(y,a,b)
dydt = zeros(2,1);
dydt(1) = _____; % you fill in this stuff based on the above
dydt(2) = _____; % you fill in this stuff based on the above
end
Then the function handle that you will pass to ode45 will simply be
odefun = @(t,y) yderivative(y,a,b)
Note that you need to have the constants "a" and "b" defined before you create the odefun function handle above. If you change "a" and "b" later on to run a different case, then you will also have to subsequently recreate the function handle so it will be using the new values of "a" and "b".
This should get you started. Use all of the above, along with the 2nd order ODE example "Pass Extra Parameters to ODE Function" on the following link, to get your solution:
https://www.mathworks.com/help/matlab/ref/ode45.html?searchHighlight=ode45&s_tid=doc_srchtitle

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 프로그래밍에 대해 자세히 알아보기

제품

태그

질문:

2017년 9월 6일

편집:

2017년 9월 6일

Community Treasure Hunt

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

Start Hunting!