フィルターのクリア

the Runge-Kutta integration scheme

1 回表示 (過去 30 日間)
Lam Chun Ting
Lam Chun Ting 2012 年 11 月 16 日
implement Runge-Kutta integration scheme with the delta=0.005
dx/dt=-x*(2-y), t0=0, x(t0)=1
dy/dt=y*(1-2*x), t0=0, y(t0)=2
but I am not sure the matlab code for Runge-Kutta integration method 4 steps
May anyone help me please?
Many thanks for helping!
  4 件のコメント
Jan
Jan 2012 年 11 月 20 日
You can find a lot of Runge-Kutta implementations in the net. I suggest to use one of them and convert it to Matlab. If you get problems, post the code you have and ask for a specific line of code.
Lam Chun Ting
Lam Chun Ting 2012 年 11 月 21 日
I try this in another way however, I think the phase curve is not right..Can you tell where did I get wrong please?
The following is my matlab code
function [x_out,y_out,t_out]=Runge_Kutta1(Delta_in,T0,T)
% setting up parameters of the integration
t_max=T;
t_min=T0;
Delta=Delta_in;
t=t_min:Delta:t_max;
x=zeros(1,size(t,2));
y=zeros(1,size(t,2));
z=zeros(1,2);
z(1)=1;
z(2)=2;
for i=1:size(t,2)
x(i)=z(1);
y(i)=z(2);
z1=competing_species_rhs2([z(1),z(2)]);
z2=competing_species_rhs2([z(1)+Delta/2,z(2)+Delta/2*z1]);
z3=competing_species_rhs2([z(1)+Delta/2,z(2)+Delta/2*z2]);
z4=competing_species_rhs2([z(1)+Delta,z(2)+Delta/2]);
z=z+Delta*((z1+2*z2+2*z3+z4)/6);
end;
t_out=t;
x_out=x;
y_out=y;
function z_out=competing_species_rhs2(z)
p=zeros(1,2);
p(1)=-z(1)*(2-z(2));
p(2)=z(2)*(1-2*z(1));
z_out=p;
Many thanks for helping!!

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

回答 (1 件)

Jan
Jan 2012 年 11 月 18 日
You can compare the results of your function with the one calculated by Matlab's ODE45. Which differences do you see?

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by