求matlab高手帮忙函数function dx=myfun2(t,x)dx(1)=(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-66814.3)*x(1)^2+(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-75105-37552.5*(0.8-x(1))/x(2))*x(1)*x(2)+(66814.3-104022*(0.8-x(1)-x(2))/(1-x(1)-x(2)))*x(1);dx(2)=(10
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 15:38:19
求matlab高手帮忙函数function dx=myfun2(t,x)dx(1)=(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-66814.3)*x(1)^2+(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-75105-37552.5*(0.8-x(1))/x(2))*x(1)*x(2)+(66814.3-104022*(0.8-x(1)-x(2))/(1-x(1)-x(2)))*x(1);dx(2)=(10
求matlab高手帮忙
函数
function dx=myfun2(t,x)
dx(1)=(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-66814.3)*x(1)^2+(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-75105-37552.5*(0.8-x(1))/x(2))*x(1)*x(2)+(66814.3-104022*(0.8-x(1)-x(2))/(1-x(1)-x(2)))*x(1);
dx(2)=(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-75105-37552.5*(0.8-x(1))/x(2))*x(2)^2+(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-66814.3)*x(1)*x(2)+(75105+37552.5*(0.8-x(1))/x(2)-104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))*x(2);
dx=dx(:);
主程序
x0=[0.7,0.2];
t0=0.001:0.001:20;
[t,x]=ode45('myfun2',[0.001,20],x0); %ode45会自动调整步长
plot(t,x)
legend('x','y')
运行会出现以下错误:
Error:File:myfun2.m Line:3 Column:227
Unbalanced or unexpected parenthesis or bracket.
Error using ==> nargin
Error:File:myfun2.m Line:3 Column:212
Unbalanced or unexpected parenthesis or bracket.
Error in ==> odearguments at 81
if (nargin(ode) == 2)
Error in ==> ode45 at 173
[neq,tspan,ntspan,next,t0,tfinal,tdir,y0,f0,odeArgs,odeFcn,...
Error in ==> zhuchengxu at 3
[t,x]=ode45('myfun2',[0.001,20],x0); %ode45会自动调整步长
请高手帮我找出到底错在哪了,该怎么修改呢?
求matlab高手帮忙函数function dx=myfun2(t,x)dx(1)=(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-66814.3)*x(1)^2+(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-75105-37552.5*(0.8-x(1))/x(2))*x(1)*x(2)+(66814.3-104022*(0.8-x(1)-x(2))/(1-x(1)-x(2)))*x(1);dx(2)=(10
function dx=myfun2(t,x)
dx(1)=(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-66814.3)*x(1)^2+(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-75105-37552.5*(0.8-x(1))/x(2))*x(1)*x(2)+(66814.3-104022*(0.8-x(1)-x(2))/(1-x(1)-x(2)))*x(1);
dx(2)=(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-75105-37552.5*(0.8-x(1))/x(2))*x(2)^2+(104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))-66814.3)*x(1)*x(2)+(75105+37552.5*(0.8-x(1))/x(2)-104022*(0.8-x(1)-x(2))/(1-x(1)-x(2))*x(2));%%这里最后加一个括号
dx=dx(:);
end
楼主要仔细啊,细节决定成败