📄 rk_4.m
字号:
function [tout,yout]=rk_4(odefile,tspan,y0)
t0=tspan(1); th=tspan(2);
if length(tspan)<=3, h=tspan(3);
else, h=tspan(2)-tspan(1); th=tspan(2); end
tout=[t0:h:th]'; yout=[];
for t=tout'
k1=h*eval([odefile '(t,y0)']);
k2=h*eval([odefile '(t+h/2,y0+0.5*k1)']);
k3=h*eval([odefile '(t+h/2,y0+0.5*k2)']);
k4=h*eval([odefile '(t+h,y0+k3)']);
y0=y0+(k1+2*k2+2*k3+k4)/6;
yout=[yout; y0'];
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -