声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2241|回复: 5

[编程技巧] 高手帮忙分析下(关于matcont的一个问题) 不会占用您多少时间的 谢谢!

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

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

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

x
高手帮忙分析下(关于matcont的一个问题) 不会占用您多少时间的 谢谢!
我完全按照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.

我是新手 哪位愿意和我讨论的 请加我qq:652491109

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 19:39 | 显示全部楼层

回复 楼主 cnee 的帖子

matcont是什么东西啊?好像这里懂的人不多啊。
发表于 2008-12-13 22:45 | 显示全部楼层

回复 楼主 cnee 的帖子

init_EP_EP
contset
cont
这些函数都是LZ自己编的吗?
发表于 2008-12-13 23:02 | 显示全部楼层
不懂,如果是你自己的我觉得你的水平比我高
 楼主| 发表于 2008-12-14 12:51 | 显示全部楼层
init_EP_EP
contset
cont
这些函数都是matlab自带的
有会的吗 谢谢帮忙了!!!
发表于 2008-12-14 12:59 | 显示全部楼层

回复 5楼 cnee 的帖子

这些函数应该不是matlab自带的,用
doc init_EP_EP
doc contset
doc cont
显示Reference Page Not Found
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-5-17 19:45 , Processed in 0.106133 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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