Euler's Method for second order ODE

16 ビュー (過去 30 日間)
Mohamed T. Adam
Mohamed T. Adam 2022 年 1 月 16 日
回答済み: Abhiroop Rastogi 2022 年 2 月 15 日
Hello, i am trying to solve y''+(1/2)*y'+5y=0 with initial values of y'(0)=2 and y(0) = 0 using Euler's method. This is my code, can you please tell me how to fix it?
  1 件のコメント
Torsten
Torsten 2022 年 1 月 16 日
編集済み: Torsten 2022 年 1 月 16 日
Implement your ODE y''+1/2*y'+5y = 0 in function "func", reduce h from 0.5 to 0.05, and the code will run fine.

サインインしてコメントする。

回答 (1 件)

Abhiroop Rastogi
Abhiroop Rastogi 2022 年 2 月 15 日
Hi Mohamed T. Adam,
The implementation of the differential equation, in the method that you have applied in your code, is not accurate. The way your equation would be represented is as follows:
You can find the the above implementation in the file attatched, named "Modified.m", for the modified code. The final output for the above equation will look as given in the figure below.

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by