matlab解微分方程组,这个程序报错,求指导如何改~function x_dot=cha721lotka_volterra(t,x)x_dot=zeros(2,1);x=zeros(2,1);x_dot=[4*x(1)-2*x(1)*x(2);x(1)*x(2)-3*x(2)];t_final=100;x0=[2,3];[t,x]=ode45('cha721lotka_volterra',[0,t_final],x0);p
来源:学生作业帮助网 编辑:六六作业网 时间:2024/09/08 02:13:56
matlab解微分方程组,这个程序报错,求指导如何改~function x_dot=cha721lotka_volterra(t,x)x_dot=zeros(2,1);x=zeros(2,1);x_dot=[4*x(1)-2*x(1)*x(2);x(1)*x(2)-3*x(2)];t_final=100;x0=[2,3];[t,x]=ode45('cha721lotka_volterra',[0,t_final],x0);p
matlab解微分方程组,这个程序报错,求指导如何改~
function x_dot=cha721lotka_volterra(t,x)
x_dot=zeros(2,1);
x=zeros(2,1);
x_dot=[4*x(1)-2*x(1)*x(2);
x(1)*x(2)-3*x(2)];
t_final=100;
x0=[2,3];
[t,x]=ode45('cha721lotka_volterra',[0,t_final],x0);
plot(t,x)
matlab解微分方程组,这个程序报错,求指导如何改~function x_dot=cha721lotka_volterra(t,x)x_dot=zeros(2,1);x=zeros(2,1);x_dot=[4*x(1)-2*x(1)*x(2);x(1)*x(2)-3*x(2)];t_final=100;x0=[2,3];[t,x]=ode45('cha721lotka_volterra',[0,t_final],x0);p
昨天不是回了一个吗?
在Matlab下输入:edit,然后将下面两行百分号之间的内容,复制进去,保存
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function dxdt=zhidao_rk4_t55262177(t,x)
k1=1000;k2=1000;i1=4;i2=4;g1=10500;g2=4700;n=0.2; %把这个g2改成4700就可以了.
dxdt=[
-k1*(x(1)+n*x(2))+g1*x(1)*x(3);
-k2*(x(2)-n*x(1))+g2*x(2)*x(4);
-(1+i1+abs(x(1))^2)*x(3)+i1-1;
-(1+i2+abs(x(2))^2)*x(4)+i2-1;
];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
在Matlab下面输入:
t_start=0;
t_end=10;
xx0=[0;1;0;0]; %初值
[t,x]=ode45('zhidao_rk4_t55262177',[0,t_end],xx0);
plot(x(:,1),x(:,2));
xlabel('x(1)');
ylabel('x(2)');
%具体的可以看一下论坛:
%