I want to solve this equation using Runge-Kutta 4th order method. d(ADH)/dt =(ADHS- ADH*DADH)/PV.

2 次查看(过去 30 天)
h=1; % step size
x = 0:h:3; % Calculates upto y(3)
y = zeros(1,length(x));
y(1) = 4; % initial condition
F_xy = @(t,ADH) (ADHS- ADH*DADH)/PV;
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
But I am not getting answer. On the workspace, it says F_xy=@(t,ADH) (ADHS- ADH*DADH)/PV. It doesn't say error.
How can I get the answer. Can I get the answer both in numerical form and graphical form?

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Ordinary Differential Equations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by