24小时热门版块排行榜    

CyRhmU.jpeg
南方科技大学公共卫生及应急管理学院2025级博士研究生招生报考通知
查看: 1286  |  回复: 3

zhs4276689

木虫 (正式写手)

[求助] 用matlab求解方程出问题,请帮忙看看

我求解一个方程,中间虽然解出来了,但还是有些问题,请帮忙看下
程序:
clc;
Ts=800; Cs=1134;ks=218;  Ps=2591;
Tm=933;
Cl=921;
z=0.65
as=ks/Cs/Ps

t=ks*(Tm-Ts)*exp(-z^2)/sqrt(as)/(1+erf(z))
f31=@(x)(t-(60.3+0.033*x)*(x-Tm)*exp(-z^2*as/(2.39e-5+1.9e-8*x))/sqrt(2.39e-5+1.9e-8*x)*erf(z*sqrt(as/(2.39e-5+1.9e-8*x))))
x=fsolve(f31,1100)
Ts
f(1)=t-(60.3+0.033*x)*(x-Tm)*exp(-z^2*as/(2.39e-5+1.9e-8*x))/sqrt(2.39e-5+1.9e-8*x)*erf(z*sqrt(as/(2.39e-5+1.9e-8*x)));
f

结果:

Equation solved, fsolve stalled.

fsolve stopped because the relative size of the current step is less than the
default value of the step size tolerance squared and the vector of function values
is near zero as measured by the default value of the function tolerance.




x =

  1.1734e+003


Ts =

   800


f =

-2.3283e-010

请问是什么问题?如何解决?谢谢!
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★
感谢参与,应助指数 +1
zhs4276689(金币+5): 谢谢,继续帮我解答哦,呵呵 2012-03-05 16:28:18
clc;
Ts=800; Cs=1134;ks=218;  Ps=2591;
Tm=933;
Cl=921;
z=0.65
as=ks/Cs/Ps
t=ks*(Tm-Ts)*exp(-z^2)/sqrt(as)/(1+erf(z))
f31=@(x)(t-(60.3+0.033*x)*(x-Tm)*exp(-z^2*as/(2.39e-5+1.9e-8*x))/sqrt(2.39e-5+1.9e-8*x)*erf(z*sqrt(as/(2.39e-5+1.9e-8*x))))
[x,feval,exflag]=fsolve(f31,10,optimset('TolFun',1e-8))

[x,feval,exflag]=fsolve(f31,10,optimset('TolFun',1e-8))

Equation solved, fsolve stalled.

fsolve stopped because the relative size of the current step is less than the
default 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.




x =

  1.1734e+003


feval =

-2.3283e-010


exflag =

     2
我觉得,没什么大的问题,计算的值 -2.3283e-010距离0已经足够接近了,你如果还不满足,那需要调节一些参数。
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
2楼2012-03-05 15:38:56
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

zhs4276689

木虫 (正式写手)

引用回帖:
: Originally posted by dbb627 at 2012-03-05 15:38:56:
clc;
Ts=800; Cs=1134;ks=218;  Ps=2591;
Tm=933;
Cl=921;
z=0.65
as=ks/Cs/Ps
t=ks*(Tm-Ts)*exp(-z^2)/sqrt(as)/(1+erf(z))
f31=@(x)(t-(60.3+0.033*x)*(x-Tm)*exp(-z^2*as/(2.39e-5+1.9e-8*x))/sqrt(2.3 ...

就是中间出现提示,觉得不舒服。
另外我在用另一种方法进行求解时,也老出现这样的问题,或者说是solve 提前结束,但计算出的值距离0也很近,这样解出的结果可信吗?会不会根据赋值的不同,还会出现一个更适合实际的结果呢?
3楼2012-03-05 16:31:37
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
zhs4276689(金币+15): 谢谢! 2012-03-05 17:46:47
中间出现提示可以关闭,在optimset中设置一下,这个看你初值给的怎么样,一般来说你要求的精度不是非常高的话,是可以接受的
clc;
Ts=800; Cs=1134;ks=218;  Ps=2591;
Tm=933;
Cl=921;
z=0.65
as=ks/Cs/Ps
t=ks*(Tm-Ts)*exp(-z^2)/sqrt(as)/(1+erf(z))
f31=@(x)(t-(60.3+0.033*x)*(x-Tm)*exp(-z^2*as/(2.39e-5+1.9e-8*x))/sqrt(2.39e-5+1.9e-8*x)*erf(z*sqrt(as/(2.39e-5+1.9e-8*x))))
[x,feval,exflag]=fsolve(f31,10,optimset( 'Display','off',TolFun',1e-8))
x =

  1.1734e+003


feval =

-2.3283e-010


exflag =

     2

fsolve的exflag =     2 表示  2  Change in X too small. 可以认为已经收敛了

  1  FSOLVE converged to a root.
      2  Change in X too small.
      3  Change in residual norm too small.
      4  Computed search direction too small.
      0  Too many function evaluations or iterations.
     -1  Stopped by output/plot function.
     -2  Converged to a point that is not a root.
     -3  Trust region radius too small (Trust-region-dogleg) or
         Regularization parameter too large (Levenberg-Marquardt).
     -4  Line search failed.
The more you learn, the more you know, the more you know, and the more you forget. The more you forget, the less you know. So why bother to learn.
4楼2012-03-05 17:11:12
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zhs4276689 的主题更新
信息提示
请填处理意见