ode45的格式:
[t,y] = ode45(odefun,tspan,y0)
[t,y] = ode45(odefun,tspan,y0,options)
[t,y,te,ye,ie] = ode45(odefun,tspan,y0,options)
sol = ode45(___)
一阶微分方程:
示例:
首先创建一个func2.m函数存放方程表达式:
functionBiubiu = func2(h, t)
g = 9.8;
Biubiu = (10000*pi/sqrt(2*g))*(h.^(3/2) - 2*(h.^(1/2)));
end
接着在MATLAB命令窗口输入:
tspan = [1 0];%函数范围
t_1 = 0;%初值
[h,t] = ode45(@func2, hspan, t_1);
plot(h,t);%绘图