Rewrite your 2nd order equation as a pair of first order equations, then use Euler method on a 2-element vector. I.e.,
Define your 2-element state vector y as
y(1) is defined to be x
y(2) is defined to be xdot
The derivative of y(1) is y(2) by definition.
The derivative of y(2) can be found by solving your 2nd order DE for xdotdot.
See the van der Pol equation example in the doc here for an example of turning a 2nd order DE into a pair of 1st order DEs:
You can essentially use your 1st order Euler code as an outline for this 2nd order system. Simply replace the scalar state with a 2-element vector state in your code.
4 件のコメント
James Tursa (view profile)
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/459658-second-oder-ode-solution-with-euler-methods#comment_700585
Bayram FURKAN TORA (view profile)
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/459658-second-oder-ode-solution-with-euler-methods#comment_700586
Erivelton Gualter (view profile)
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/459658-second-oder-ode-solution-with-euler-methods#comment_700588
Bayram FURKAN TORA (view profile)
このコメントへの直接リンク
https://jp.mathworks.com/matlabcentral/answers/459658-second-oder-ode-solution-with-euler-methods#comment_700596
サインイン to comment.