Solving Coupled ODE's with Runge Kutta.

3 ビュー (過去 30 日間)
Oliver Bradley
Oliver Bradley 2018 年 3 月 22 日
回答済み: James Tursa 2018 年 3 月 22 日
I want to solve a second order ODE of the form y''=Ey. To do this I've written my own Runge-Kutta function, which applies the 4th order Runge Kutta method to a function'f', defined using a function handle. To do this I have separated the ODE to a coupled first order system: y'=v, v'=Ey. However, I can't think of a way to input this coupled system with function handles. Is there a way to do this?

回答 (1 件)

James Tursa
James Tursa 2018 年 3 月 22 日
Do it the same way the examples for ode45 do it in the doc. Let your state vector be two elements with
y(1) = your original y
y(2) = your original v
Then you can have a function handle as follows:
dy = @(y) [y(2);E*y(1)];

製品

Community Treasure Hunt

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

Start Hunting!

Translated by