马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?我要加入
x
我完全按照matcont的manual上平衡点的那个例子(bratu) 但是matlab还是报错:
>> [x0,v0]=init_EP_EP(@bratu,[0;0],p,ap);
??? Error: File: bratu.m Line: 48 Column: 1
The function "bratu" was closed
with an 'end', but at least one other function definition was not.
To avoid confusion when using nested functions,
it is illegal to use both conventions in the same file.
Error in ==> init_EP_EP at 15
func_handles = feval(odefile);
去掉end后 这项命令可以运行了
但是到最后一步又报错:
>> [x,v,s,h,f]=cont(@equilibrium,x0,[],opt);
??? Error using ==> feval
Argument must contain a string or function_handle.
Error in ==> cjacp at 11
j = feval(jacobianp, 0, x, p{:});
Error in ==> equilibrium>jacobian at 29
jac = [cjac(eds.func,eds.Jacobian,x,p,eds.ActiveParams) cjacp(eds.func,eds.JacobianP,x,p,eds.ActiveParams)];
Error in ==> cjac at 52
j = feval(jacobian,x);
Error in ==> newtcorr at 14
B = [cjac(cds.curve_func,cds.curve_jacobian,x,[]); v'];
Error in ==> cont>CorrectStartPoint at 753
[x,v] = newtcorr(x0, v0);
Error in ==> cont at 208
[x0, v0] = CorrectStartPoint(x0, v0);
附程序:bratu.m
function out =bratu
out{1}=@init;
out{2}=@fun_eval;
out{3}=@jacobian;
out{4}=[];
out{5}=@hessians;
out{6}=@hessiansp;
out{7}=[];
out{8}=[];
out{9}=[];
out{10}=@userf1;
end
%-----------------------------------------------------------
function dydt=fun_eval(t,kmrgd,a)
dydt=[-2*kmrgd(1)+kmrgd(2)+a*exp(kmrgd(1));
kmrgd(1)-2*kmrgd(2)+a*exp(kmrgd(2))];
%-----------------------------------------------------------
function [tspan,y0,options]=init
tspan=[0;10];
y0=[0;0];handles=feval(@bratu)
options=odeset('Jacobian',handles(3),'JacobianP','handles(4)','Hessians',handles(5),'Hessiansp',handles(6));
%-----------------------------------------------------------
function jac=jacobian(t,kmrgd,a)
jac=[-2+a*exp(kmrgd(1)) 1
1 -2+a*exp(kmrgd(2)) ];
%-----------------------------------------------------------
function jacp=jacobianp(t,kmrgd,a)
jacp=[exp(kmrgd(1))
exp(kmrgd(2))];
%-----------------------------------------------------------
function hess=hessians(t,kmrgd,a)
hess1=[[a*exp(kmrgd(1)),0];[0,0]];
hess2=[[0,0];[0,a*exp(kmrgd(2))]];
hess(:,:,1)=hess1;
hess(:,:,2)=hess2;
%-----------------------------------------------------------
function hessp=hessiansp(t,kmrgd,a)
hessp1=[[exp(kmrgd(1)),0];[0,exp(kmrgd(2))]];
hessp(:,:,1)=hessp1;
%-----------------------------------------------------------
function userfun1=userf1(t,kmrgd,a)
userfun1=a-0.2;
应该输入的命令行:
>> global cds
>> p=0;ap=1;
>> [x0,v0]=init_EP_EP(@bratu,[0;0],p,ap);
>> opt=contset;opt=contset(opt,'MaxNumPoints',50);
>> opt=contset(opt,'Singularities',1);
>> opt=contset(opt,'Userfunctions',1);
>> UserInfo.name='userf1';UserInfo.state=1;UserInfo.label='u1';
>> opt=contset(opt,'UserfunctionsInfo',UserInfo);
>> [x,v,s,h,f]=cont(@equilibrium,x0,[],opt); |