How to resolve ODE system in Matlab using numerical method Runge-Kuta?

1 回表示 (過去 30 日間)
Patrick
Patrick 2014 年 2 月 2 日
編集済み: Amit 2014 年 2 月 2 日
the ODE system is like that : y'(1)=y(2); Y'(2)=k1Y(3)+k2Y(2); Y'(3)=k3Y(4); Y'(4)=k4Y(2);

回答 (1 件)

Amit
Amit 2014 年 2 月 2 日
編集済み: Amit 2014 年 2 月 2 日
First You'll have to make a function for your problem. This function take (time and Y) and will return dy
function dy = myfunc(t,y)
dy = zeros(size(y));
% Define k1 etc
k1 = 1;
k2 = 1;
k3 = 1;
k4 = 1;
dy(1) = y(2);
dy(2)=k1*Y(3)+k2*Y(2);
dy(3)=k3*Y(4);
dy(4)=k4*Y(2);
Now you can solve it using ode45 (RK45) solver like
Y0 = [0 1 1 1]; % Intial Value
[T,Y] = ode45(@myfunc,[0 12],Y0);
For moredetails on ode45 and other ode solvers: http://www.mathworks.com/help/matlab/ref/ode45.html

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by