function [dx] = equation (t,X)#t必不可少,X为变量
C=[1 0.8 0.5];
B=[0.1 0.03 0.06];
a1=0.2;
dx=zeros(3,1);
dx(1)=X(1)*(C(1)-B(1)*X(2));
dx(2)=X(2)*(-C(2)-B(2)*X(1)-a1*X(3));
dx(3)=X(3)*(-C(3)+B(3)*X(2));
end
===== 求解微分方程组 =====
-------
X0=[200 60 15];#初值
T=2;
[t,X]=ode45(@my_equation,[0,T],X0);#函数句柄,时间区间,初始值
plot(t,X(:,1));
hold on;
plot(t,X(:,2));
hold on;
plot(t,X(:,3));
legend('x1','x2','x3')