runge-kutta
古いコメントを表示
hello i have this equation y''+3y'+5y=1 how can i solve it by programming a runge kutta 4'th order method ? i know how to solve it by using a pen and paper but i can not understand how to programe it please any one can solve to me this problem ? i dont have any idea about how to use ODE and i read the help in matlab but did not understand how to solve this equation please any one can solve this and help me with it ? thanx
採用された回答
その他の回答 (1 件)
Richard Brown
2012 年 4 月 22 日
3 投票
I'll give you the high level overview, you'll need to write the code though
- Turn it into a system of two first order equations (define a new variable z = y')
- Find a decent pseudocode representation of the algorithm, either from your lecture notes or from e.g. section 8.3 of Kincaid and Chaney, "Numerical Analysis", or Algorithm 5.2 of Burden and Faires, "Numerical Analysis", both of which are readily available introductory books that should be in your library.
- Try and code it up in MATLAB
- Report back if you have any problems
4 件のコメント
rana
2012 年 4 月 23 日
rana
2012 年 4 月 23 日
Richard Brown
2012 年 4 月 23 日
You've defined your system correctly, however I suggest you use a function, because you're going to need to evaluate it at many different x values, which can get confusing. Something like
f = @(x) [x(2); -3*x(2) - 5*x(1) + u];
You can then call f(x) (where x is a 2-element vector) to get your derivatives (also as a vector).
Wikipedia also has the basic RK4 here <http://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods#Common_fourth-order_Runge.E2.80.93Kutta_method>, you should be able to use that pretty much the way it is written ...
rana
2012 年 4 月 23 日
カテゴリ
ヘルプ センター および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!