声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1592|回复: 3

[动力学和稳定性] 高手帮忙分析下(关于matcont的一个问题) 不会占用您多少时间的 谢谢!

[复制链接]
发表于 2008-12-13 16:27 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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);
回复
分享到:

使用道具 举报

 楼主| 发表于 2008-12-13 16:28 | 显示全部楼层

我是新手 有愿意和我讨论的 请加我qq

qq:652491109:@)
 楼主| 发表于 2008-12-14 12:49 | 显示全部楼层
有没有会的啊 感谢了!!!
 楼主| 发表于 2008-12-15 13:43 | 显示全部楼层
帮下忙啊 我调了好几个例子 都报错 哪位达人帮我看看哪里还需要改下的啊 谢谢了
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-17 18:11 , Processed in 0.069928 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表