24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1689  |  回复: 9
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

zhangluyoa

银虫 (初入文坛)

[求助] 求解扩散方程问题

有一个方程如图
源码是
function AA
D0=3.55e-19;
options=optimset('tolx',1e-9);
[D,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(@fei,D0,[],[],options)

function F=fei(D)
C0=0.687;
d=0.02;
Ceq=20;
t=60;
C=4.136;
m=1-(C0-C)/(C0-Ceq);
s=[];
k=0:1000;
s=sum(8./(pi*(2*k+1)).^2.*exp(-D*(pi*(2*k+1)).^2*t*60/(d^2)));
s
F=sum((m-s').^2);


而得到的结果怎么也不对 如下
得到的D值怎么都是跟赋的D0值是一样的额
s =

    0.9998


s =

    0.2158


s =

   Inf


s =

    0.2447


s =

   Inf


s =

    0.2161

Optimization terminated: norm of the current step is less
than OPTIONS.TolX.

D =

  3.5500e-019


resnorm =

    0.0010


residual =

    0.0318


exitflag =

     2


output =

    firstorderopt: 7.1546e+005
       iterations: 2
        funcCount: 6
     cgiterations: 1
        algorithm: 'large-scale: trust-region reflective Newton'
          message: [1x77 char]


lambda =

    lower: 0
    upper: 0


jacobian =

   (1,1)     2.2480e+007
到底怎么弄得,小弟是菜鸟,希望有高手跟好心人帮我5555
回复此楼

» 猜你喜欢

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

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

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
臭水沟: 金币+3, 谢谢交流~~ 2012-04-04 11:15:22
zhangluyoa: 金币+4, 有帮助 2012-04-11 16:35:41
CODE:
D0=3.55e-6;
options=optimset('tolx',1e-9);
[D,resnorm,residual,exitflag,output,lambda,jacobian] = lsqnonlin(@fei,D0,[],[],options)

function F=fei(D)
C0=0.687;
d=0.02;
Ceq=20;
t=60;
C=4.136;
m=1-(C0-C)/(C0-Ceq);
s=[];
k=0:5000;
s=sum(8./(pi*(2*k+1)).^2.*exp(-D*(pi*(2*k+1)).^2[color=red]*t[/color]/(d^2)));
F=sum((m-s').^2);

Local minimum possible.

lsqnonlin stopped because the final change in the sum of squares relative to
its initial value is less than the default value of the function tolerance.




D =

  5.0774e-008


resnorm =

  1.1370e-007


residual =

  3.3720e-004


exitflag =

     3


output =

    firstorderopt: 39.0251
       iterations: 13
        funcCount: 28
     cgiterations: 0
        algorithm: 'large-scale: trust-region reflective Newton'
          message: [1x458 char]


lambda =

    lower: 0
    upper: 0


jacobian =

   (1,1)     1.1573e+005
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.
6楼2012-04-03 17:56:51
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

★ ★ ★
臭水沟: 金币+1, 谢谢交流~~ 2012-04-04 11:15:29
zhangluyoa: 金币+2, 有帮助 2012-04-11 16:35:57
s=sum(8./(pi*(2*k+1)).^2.*exp(-D*(pi*(2*k+1)).^2*t*60/(d^2))); 多乘了60?
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.
7楼2012-04-03 17:58:17
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zhangluyoa 的主题更新
信息提示
请填处理意见