フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

solve runge kutta method

1 回表示 (過去 30 日間)
Mariam Gasra
Mariam Gasra 2019 年 5 月 15 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
lamda=0.2;
mu=0.8;
h=0.1; % step size
x = 0:h:5; % Calculates upto y(3)
Y = zeros(1,length(x));
y(1) = 0.2; % redo with other choices here.
% initial condition
%F_xy = @(??,??) (lamda^2/(lamda+mu)^2)*exp(-2(lamda+mu)*t)+((2*mu*lamda)/(lamda+mu)^2)*exp(-(mu+lamda)*t)+mu^2/(lamda+mu)^2;
for i=1:(length(x)-1) % calculation loop
k_1 = F_xy(x(i),y(i));
k_2 = F_xy(x(i)+0.5*h,y(i)+0.5*h*k_1);
k_3 = F_xy((x(i)+0.5*h),(y(i)+0.5*h*k_2));
k_4 = F_xy((x(i)+h),(y(i)+k_3*h));
y(i+1) = y(i) + (1/6)*(k_1+2*k_2+2*k_3+k_4)*h; % main equation
end
% validate using a decent ODE integrator
tspan = [0,5]; y0 = -0.5;
[tx, yx] = ode45(F_xy, tspan, y0)
plot(x,y,'o-', tx, yx, '--')
if i have this equation F_xy=(lamda^2/(lamda+mu)^2)*exp(-2(lamda+mu)*t)+((2*mu*lamda)/(lamda+mu)^2)*exp(-(mu+lamda)*t)+mu^2/(lamda+mu)^2
the variable only t
how can correct the code to get the answer?
  1 件のコメント
James Tursa
James Tursa 2019 年 5 月 15 日
編集済み: James Tursa 2019 年 5 月 15 日
Can you show the code you are using for the F_xy function? Can you post the original DE you are trying to solve?

回答 (0 件)

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by