matlab求解x1’=a*x1-b*x1*x2 X2’=c*x1*x2-d*x2 其中a=2,b=

发布时间:2021-02-25 06:39:25

matlab求解x1’=a*x1-b*x1*x2 X2’=c*x1*x2-d*x2 其中a=2,b=0.01,c=0.001,d=0.7.x1(0)=300,x2(0)=100function dx=preyer(t,x,flag,a,b,c,d);dx(1,1)=a*x(1)-b*x(1)*x(2);dx(2,1)=c*x(1)*x(2)-d*x(2);tspan=[0,14];x0=[300,

网友回答

1.新建function函数
function dx=preyer(t,x);
a=2;b=0.01;c=0.001;d=0.7;
dx=zeros(2,1);
dx(1)=a*x(1)-b*x(1)*x(2);
dx(2)=c*x(1)*x(2)-d*x(2);
2.[t,x]=ode45(@preyer,[0 14],[300 100]);
figure('position',[121 233 1121 406])
plot(t,x)
set(gcf,'color','w')
set(gca,'fontsize',12)
xlabel('\itt','fontsize',16)
ylabel('\itx','fontsize',16)
L=legend('{\itx}_1','{\itx}_2',0);
legend boxoff
set(L,'fontname','Times New Roman')
看看是不是你想要的结果
以上问题属网友观点,不代表本站立场,仅供参考!