24小时热门版块排行榜    

查看: 1753  |  回复: 13

vs570588

木虫 (正式写手)

[求助] 求高手,拟合求参数

function M=Monod(c,Y)
M= -c(1).*Y./(Y+c(2))


Y=[255.55 246.44 237.28 228.36 136.08 114 99.16 82.33 69.4 56.94 42.31 0];
x=[-0.78 -2.2268 -5.2033 -6.1377 -8.6137 -8.6428 -8.4792 -8.1692 -7.7128 -7.11 -6.3608 -1.9];
x=x/214.63;
c0=[0.03 0.3];beta=nlinfit(Y,x ,’Monod’,c0);
为了参数c(1),c(2),这个小程序快把我折磨死了。现在出来NLINFIT did NOT converge. Returning results from last iteration.
beta =

    0.0271
   -8.1892
按道理,-8.1892不合理。出来的参数应该和我预估的差不多。大家看看,这是怎样回事?
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

lidaxue

木虫 (正式写手)

之乎者也

【答案】应助回帖


sunyang1988(金币+1): 谢谢交流 2011-06-01 18:34:14
楼主的函数文件里面,好像没有涉及到x的啊,还有你的x=x/214.63;啥意思?
Comeon!
2楼2011-05-31 10:06:39
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

vs570588

木虫 (正式写手)

引用回帖:
Originally posted by lidaxue at 2011-05-31 10:06:39:
楼主的函数文件里面,好像没有涉及到x的啊,还有你的x=x/214.63;啥意思?

谢谢你回复,这是我的问题,你看看,有啥办法能解决?ds/dt  =  -q*S*X/(k+S)这里未知参数是q和K, q是比最大降解速率,K是半饱和常数,X是污泥浓度214.63,这个值是定值。S是污染物的浓度, t肯定就是时间了。我具体试验是隔一段时间,取一个样品测出S,所以我最原始数据是
t=[0 2 7 9 19 22 24 26 28 30 32 40];
S=[255.55 246.44 237.28 228.36 136.08 114 99.16 82.33 69.4 56.94 42.31 0];
就那这一组数据来拟合出上面微分方程里中的未知参数。你看能用啥好办法?另外,我也看宋新山《matlab在环境科学中的应用》,上面也用个例子,但是有个例子直接给出了一系列ds/dt的值,并且这些值呈递增。但你也知道,实际试验不会出现这种理想情况。所以我求ds/dt值是用多项式拟合,求各个点的导数,肯定这样误差大。但我实在想不出好办法。也有人说用有限差分法,求出数值解,再代入,求最优化参数。
3楼2011-05-31 16:42:18
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

lidaxue

木虫 (正式写手)

之乎者也

【答案】应助回帖


sunyang1988(金币+1): 谢谢交流 2011-06-01 18:34:23
vs570588(金币+1): 谢谢你了 2011-06-05 20:54:19
楼主你好,看了你的问题,其实不是很难,请楼主参考我给你的ppt,里面有个问题和你的问题比较相似,时间挺紧,还请楼主多多努力!
Comeon!
4楼2011-05-31 18:47:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

vs570588

木虫 (正式写手)

引用回帖:
Originally posted by lidaxue at 2011-05-31 18:47:03:
楼主你好,看了你的问题,其实不是很难,请楼主参考我给你的ppt,里面有个问题和你的问题比较相似,时间挺紧,还请楼主多多努力!

你好,我用你给介绍的,参考别人写的程序,用数值解求参数,程序写的很繁琐,你能帮我改改吗?另外,现在运行不下去,提示说divided by zero.你能给看看,怎样把数据处理就能好些?
S=dsolve(‘Dy=-k1*y*214.63/(y+k2)’,’y(0)= 255.55’)
simplify(S)                                        %微分方程积分,求出来式子相当繁琐


function monodfit2
clear all;
t= [0 2 7 9 19 22 24 26 28 30 32 40]’;
c=[255.55 246.44 237.28 228.36 136.08 114 99.16 82.33 69.4 56.94 42.31 0]’;
[y_row,y_col]=size(c);
beta0=[0.03,0.3];
c0=255.55;
lb=[0 0];ub=[inf inf];
[beta,resnorm,residual,exitflag,output,lambda,jacobian] = ...
    lsqnonlin(@seqfun,beta0,lb,ub,[],t,c,y_col,c0);
ci = nlparci(beta,residual,jacobian);
function y = seqfun(beta,t,c,y_col,c0)      % Objective function
tspan = [0  max(t)];
[tt yy] = ode45(@modeleqs,tspan,c0,[],beta);
for col = 1:y_col
    yc(:,col) = spline(tt,yy(:,col),t);
end
y=[c(:,1)-yc(:,1)];

function dydt = modeleqs(t,y,beta)       % Model equation
dydt=beta(2)*lambertw(1/beta(2)*exp(-1/100*(21463*t*beta(1)-25555-100*beta(2)*log(19)-100* beta(2)*log(269)+200* beta(2)*log(2)+100* beta(2)*log(5))/ beta(2)));
5楼2011-06-02 15:08:43
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

t= [0 2 7 9 19 22 24 26 28 30 32 40]';
c=[255.55 246.44 237.28 228.36 136.08 114 99.16 82.33 69.4 56.94 42.31 0]';
ft_ = fittype('k/(-1+exp(a*t)*C)',...
    'dependent',{'c'},'independent',{'t'},...
    'coefficients',{'k', 'a', 'C'});
st=[200 1.5 0.1]
[curve, goodness]= fit(t,c,ft_,'Startpoint',st)
figure
plot(curve,'predobs',0.95);
hold on,plot(t,c,'b*')

st =

  200.0000    1.5000    0.1000


curve =

     General model:
     curve(t) = k/(-1+exp(a*t)*C)
     Coefficients (with 95% confidence bounds):
       k =      -269.7  (-288.2, -251.2)
       a =      0.1438  (0.1191, 0.1685)
       C =    -0.05613  (-0.09544, -0.01682)

goodness =

           sse: 394.4838
       rsquare: 0.9955
           dfe: 9
    adjrsquare: 0.9945
          rmse: 6.6205
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楼2011-06-02 21:41:09
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

引用回帖:
Originally posted by dbb627 at 2011-06-02 21:41:09:
t= [0 2 7 9 19 22 24 26 28 30 32 40]';
c=[255.55 246.44 237.28 228.36 136.08 114 99.16 82.33 69.4 56.94 42.31 0]';
ft_ = fittype('k/(-1+exp(a*t)*C)',...
    'dependent',{'c'},'independent',{'t'} ...

maple计算解析解为 S(t)=k/(-1+exp(q*214.63*k*t)*C1*k)
令q*214.63*k=a,C1*k=C  S(t)=c
matlab拟合可得a k C
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楼2011-06-02 21:48:41
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dbb627

荣誉版主 (著名写手)

【答案】应助回帖

vs570588(金币+3): 谢谢你 2011-06-03 13:26:07
vs570588(金币+3): 十分感谢 2011-06-04 18:33:10
vs570588(金币+1): 只剩下一个,谢谢你了。希望你能再帮我看看 2011-06-05 20:55:16
引用回帖:
Originally posted by dbb627 at 2011-06-02 21:41:09:
t= [0 2 7 9 19 22 24 26 28 30 32 40]';
c=[255.55 246.44 237.28 228.36 136.08 114 99.16 82.33 69.4 56.94 42.31 0]';
ft_ = fittype('k/(-1+exp(a*t)*C)',...
    'dependent',{'c'},'independent',{'t'} ...

计算的图见附件

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.
8楼2011-06-02 21:50:44
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

vs570588

木虫 (正式写手)

引用回帖:
Originally posted by dbb627 at 2011-06-02 21:50:44:
计算的图见附件

你好,谢谢你了。你用maple做出的解析解。我matlab是个菜鸟,怎样用matlab实现,我不会。你能帮我看看吗?另外,这里还有几篇英文文献,处理类似的问题。
第一篇:
Non-linear least-square error minimization was used to estimate best-fit values for the kinetic parameters (Sa´ez and Rittmann, 1992). In this technique, the modeling equations are solved numerically, and parameters are selected to minimize the sum of the relative least-square residuals. The equations were solved by finite differences in a Microsoft Excel spreadsheet.
第二篇:
2.7.5. Data fitting
AQUASIM version 2.1f (Reichert, 1995) was used to fit kinetic parameters. AQUASIM estimates kinetic parameters by minimizing
the sum of the squares of the weighted deviations between actual data and results of the calculated model. The calculation step size was 0.01 days. The secant method was used with a maximum iteration number of 100.
第三篇:
The fitting method adopted is detailed as follows. Eqs. (1) and(8) were solved numerically by the finite-difference method with
a finite-difference of dt= 0.00625 h and with an initial guess of qmax and Ks. The optimal qmax and Ks were then obtained by
changing their values in Microsoft Excel Solver to reach the minimum SSE between the model-calculated and observed data.
我希望我出来的拟合图形不应该是折线图,而是如附件所示。我的数据和第三篇中的数据很像,也是一式三组试验,其中一组和另外两组数据有区别。第三篇拟合求参方法如上所示。
最后,还是要谢谢你。
9楼2011-06-04 18:32:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

vs570588

木虫 (正式写手)

引用回帖:
Originally posted by dbb627 at 2011-06-02 21:50:44:
计算的图见附件

不好意思,由于我多处求助,这句话不对“我希望我出来的拟合图形不应该是折线图,”。还是很感谢你。
10楼2011-06-04 18:37:03
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 学员BmWXvC 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[基金申请] 能否退出参与的面上项目解除限项 +21 koalala 2026-08-24 24/1200 2026-08-24 19:25 by 家与远方
[基金申请] filecode,4个jtjc了 +14 ziyangfang 2026-08-19 17/850 2026-08-24 18:37 by 哈哈蛤?
[基金申请] 没有任何消息-是不是就凉了 +6 图啦图啦 2026-08-24 6/300 2026-08-24 17:44 by 小小红帆
[基金申请] 如果此刻你正在为国基感到焦虑,不妨来听听这首《基金之外》 +5 scalable 2026-08-24 5/250 2026-08-24 17:03 by spiderzhuzhi
[基金申请] 建议基金发布提前给出明确的时间点 +13 kulium 2026-08-21 16/800 2026-08-24 16:27 by superceng
[基金申请] 今日不放榜?网传国自然预计 8 月 27 日可查结果 +17 医学老男孩 2026-08-20 21/1050 2026-08-24 14:21 by refreshing11
[基金申请] 估计是周四 +4 archvillain 2026-08-18 4/200 2026-08-24 13:53 by zzuzxg
[基金申请] 我面上完蛋了 +8 且听虎啸 2026-08-20 9/450 2026-08-24 13:52 by zzuzxg
[基金申请] 范进中举一文的中心思想 +6 炎黄贵胄 2026-08-22 7/350 2026-08-24 11:58 by 6543yes
[基金申请] 明天应该可查了!? +4 chengyan1220 2026-08-23 4/200 2026-08-24 08:47 by gloomy6159
[基金申请] 什么时候开奖? +10 CrisMessi 2026-08-18 11/550 2026-08-24 06:50 by 开心的小狮子
[基金申请] 2026年的国家社科基金项目通讯评审的新规则与新动向、新挑战 +4 process2012 2026-08-23 5/250 2026-08-23 19:58 by jurkat.1640
[教师之家] 跳槽后在研项目怎么办? +5 简单化xn 2026-08-22 10/500 2026-08-23 12:38 by 简单化xn
[基金申请] 只有每年这种时候来逛逛小木虫 +24 yaoyewhu2008 2026-08-20 26/1300 2026-08-22 17:43 by kammury
[基金申请] 今天基金会出结果吗?20260819 +16 kkkl_v 2026-08-19 17/850 2026-08-22 16:12 by 阿布Abu
[基金申请] 时间戳今天,20号变了 +5 archvillain 2026-08-20 5/250 2026-08-22 06:12 by hui_daxiao
[基金申请] 应该是下周三26日公布了吧? +4 哈哈蛤? 2026-08-21 4/200 2026-08-21 10:58 by Vivilian
[论文投稿] 投稿咨询 +5 wwm09 2026-08-17 7/350 2026-08-21 10:11 by 期刊论文帮手
[基金申请] 今天放榜没戏了吧 +9 yuleib84 2026-08-19 11/550 2026-08-21 10:06 by gltch
[基金申请] 重要消息,中午系统在维护 +11 yuleib84 2026-08-18 12/600 2026-08-20 11:09 by xskun
信息提示
请填处理意见