这个是我自己写的函数代码

cd=0.625;

ps=70e5;

kk=2e-12;

d=870;

xs=0.000004;

op1=(0.0000045+xs); %valve open area

op2=(0.0000045-xs);

if op1<0  % simulate the actual valve open area

Av1=0;

else

Av1=7.938e-3*pi*op1;

end

if op2<0;

Av2=0;

else

Av2=7.938e-3*pi*op2;

end

r=11.43/5.8;

p1fnc=@(p1)(cd*(2/d)^0.5*(Av1*(ps-p1)^0.5-Av2*(p1)^0.5)+kk*(p1-p1*r)*(r-1)-r*cd*(2/d)^0.5*(Av1*(p1*r)^0.5-Av2*(ps-r*p1)^0.5));

options=optimset;

options = optimset(options,'TolX',1e-16);

options = optimset(options,'TolFun',1e-20);

options = optimset(options,'MaxFunEvals',Inf);

y=fsolve(p1fnc,1e5,options);

运行结果总是:

Equation solved, fsolve stalled.

fsolve stopped because the relative size of the current step is less than the

selected value of the step size tolerance squared and the vector of function values

is near zero as measured by the selected value of the function tolerance.

自己画了一个p1fnc的图像,p1从1e5到1e6。图像如下,解是图中的红色点。已经减小了function tolerance可是还是不行啊。应该怎么设置呢。

1.png

(11.75 KB, 下载次数: 0)

2013-11-17 19:45 上传

442a53943febe9465fc072b4fbe10813.gif

b2a5a3e0dcc7d508e00275fe42fce1b5.gif

p1fnc vs p1

291ba15d635a501597d42ed4575d7559.png

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐