%主程序-求解器:ode45
clear all
close all
clc
y0 = 0;
tspan = [0:0.01:10];
[t,y] = ode45(@subfun,tspan,y0);
figure(1)
plot(t,y);% 画出每次积分结果与时间的图形
%主程序-求解器:ode15s
clear all
close all
clc
y0 = 0;
yp0 = 1;
tspan = [0:0.01:10];
options = odeset('RelTol',1e-12);
[t,y] = ode15s(@subfun,tspan,y0,yp0,options);
figure(1)
plot(t,y);% 画出每次积分结果与时间的图形
%主程序-求解器:ode15i
clear all
close all
clc
y0 = 0;
yp0 = 1;
tspan = [0:0.01:10];
options = odeset('RelTol',1e-12);
[t,y] = ode15i(@subfun,tspan,y0,yp0,options);
figure(1)
plot(t,y);% 画出每次积分结果与时间的图形
%以“subfun”命名的子函数
function f = ode(t,y,yp)
f = cos(t);
#ode45求解结果
#ode15s求解结果
#ode15i求解结果:积分公差要求无法满足:我暂时还没找到是什么原因产生的