请问这道题怎么用matlab程序写?
展开全部
可以这样写
clc;clear
odefun = @(t,y)[y(2); y(3); 3*y(3) + y(2)*y(1)];
tspan = [0,1];
y0 = [0;1;-1];
[t1, y1] = ode45(odefun, tspan, y0);
plot(t1, y1(:,1), 'k.')
hold on
plot(t1, y1(:,2), 'c.')
[t2, y2] = ode113(odefun, tspan, y0);
plot(t2, y2(:,1), 'b*')
plot(t2, y2(:,2),'r+')
legend('ode45-y_1','ode45-y_2','ode113-y_1','ode113-y_2')
e可见ode45是时间步均匀的,ode113的时间步是可变的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询