| 4 | 1/1 | 返回列表 |
| 查看: 915 | 回復(fù): 3 | ||
| 【懸賞金幣】回答本帖問題,作者修竹好衰將贈(zèng)送您 20 個(gè)金幣 | ||
修竹好衰新蟲 (初入文壇)
|
[求助]
初學(xué)用MATLAB求解動(dòng)力學(xué)模型,但是在非線性二乘法處出現(xiàn)問題 ,麻煩各位大神幫忙看看 已有2人參與
|
|
|
出現(xiàn)的問題是: 錯(cuò)誤使用 lsqncommon (line 64) The Levenberg-Marquardt algorithm does not handle bound constraints and the trust-region-reflective algorithm requires at least as many equations as variables; aborting. 出錯(cuò) lsqnonlin (line 262) lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,optimgetFlag,caller,... 出錯(cuò) kinetic (line 16) lsqnonlin(@fun,k0,lb,ub,[],yexp); 其中反應(yīng)數(shù)據(jù)是引用文件:‘reaction.xls’中每7行為一個(gè)反應(yīng)溫度下的各個(gè)時(shí)間點(diǎn)數(shù)據(jù),總共3個(gè)溫度下的數(shù)據(jù),共計(jì)21行,已在后面圖片里面顯示 程序: clc clear all; global a b tspan=[0 1 3 5 7 9 11]; %各個(gè)反應(yīng)時(shí)間點(diǎn),0h,1h,3h…… yexp=xlsread('reaction.xls') %y的賦值從reaction這個(gè)excel文件中調(diào)取 k0=[2*10^8 60000 6.75*10^10 72000 3*10^11 90000]; %每個(gè)反應(yīng)速率常數(shù)k所對(duì)應(yīng)的A、E,總計(jì)6個(gè)參數(shù)初值設(shè)定(正反應(yīng)、逆反應(yīng)、副反應(yīng)) lb=[0 0 0 0 0 0]; ub=[+inf +inf +inf +inf +inf +inf]; [k,resnorm,residual,exitflag,output,lambda,jacobian]=lsqnonlin(@fun,k0,lb,ub,[],yexp); %===================================================================================== function f=fun(k,yexp) %這個(gè)就是擬合的目標(biāo)函數(shù),得到對(duì)應(yīng)最合適的k f=[]; for i=1:3 %對(duì)應(yīng)三個(gè)溫度下的數(shù)據(jù), tspan=[0 1 3 5 7 9 11]; a=7*(i-1)+1; x0=yexp(a, ;[t,x]=ode45(@func,tspan,x0,[],k,i); d=a+6; yc1=x(:,1); yc2=x(:,2); yc3=x(:,3); yc4=x(:,4); f11=yexp(a:d,1)-yc1; f12=yexp(a:d,2)-yc2; f13=yexp(a:d,3)-yc3; f14=yexp(a:d,4)-yc4; ff=[f11 f12 f13 f14]; f=[f:ff]; end %===================================================================================== function dxdt=func(t,x,k,i) switch i case 1 m=0.6; V=0.2431; T=303.15; case 2 m=0.6; V=0.2448; T=313.15; case 3 m=0.6; V=0.2491; T=323.15; end r2=-(k(1)*exp(-k(2)/8.314/T)*x(1)/V*x(2)/V-k(3)*exp(-k(4)/8.314/T)*x(3)/V); r3=-r2; r4=k(5)*exp(-k(6)/8.314/T)*x(1)/V*x(1)/V; r1=r2-2*r4; dxdt=[m*r1;m*r2;m*r3;m*r4]; %因?yàn)檫@里r的單位是mol/(g min L)所以需要乘以質(zhì)量 |
鐵桿木蟲 (職業(yè)作家)
新蟲 (初入文壇)

| 4 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 一志愿中石油,化學(xué)工程,301求調(diào)劑 +4 | 豚饅枳枳 2026-03-04 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 324求調(diào)劑 +5 | wxz2 2026-03-03 | 8/400 |
|
|
[考研] 085600材料與化工 298 調(diào)劑 +10 | 小西笑嘻嘻 2026-03-03 | 10/500 |
|
|
[考研] 334求調(diào)劑 +6 | Trying] 2026-03-05 | 8/400 |
|
|
[考博] 26申博-目前4篇SCI一作 +4 | chen_2024 2026-03-02 | 4/200 |
|
|
[考研] 接收調(diào)劑 +19 | 津萌津萌 2026-03-02 | 29/1450 |
|
|
[考研] 304求調(diào)劑 +4 | 曼殊2266 2026-03-05 | 4/200 |
|
|
[考研] 070300化學(xué) 280 一志愿太原理工 求調(diào)劑 +8 | 拾玖壹 2026-03-04 | 8/400 |
|
|
[考研] 調(diào)劑材料學(xué)碩 +6 | 詞凝Y 2026-03-02 | 6/300 |
|
|
[考研] 材料復(fù)試調(diào)劑 +7 | 學(xué)材料的點(diǎn) 2026-03-01 | 8/400 |
|
|
[考研] 求調(diào)劑 +7 | 博斯特525 2026-03-04 | 7/350 |
|
|
[考研] 0855機(jī)械工程324求調(diào)劑 +3 | 鄭SK 2026-03-02 | 7/350 |
|
|
[考研] 295求調(diào)劑 +6 | 等春來, 2026-03-04 | 6/300 |
|
|
[考研] 293求調(diào)劑 +4 | 是樂渝哇 2026-03-03 | 4/200 |
|
|
[考研] 298求調(diào)劑 +3 | 人間唯你是清歡 2026-03-03 | 4/200 |
|
|
[考研] 295求調(diào)劑。一志愿報(bào)考鄭州大學(xué)化學(xué)工藝學(xué)碩,總分295分 +8 | yl1 2026-03-02 | 9/450 |
|
|
[考研] 求調(diào)劑 +7 | repeatt?t 2026-02-28 | 7/350 |
|
|
[考研] 291 求調(diào)劑 +3 | 化工2026屆畢業(yè)?/a> 2026-03-02 | 3/150 |
|
|
[考研] 295復(fù)試調(diào)劑 +3 | 簡木ChuFront 2026-03-01 | 3/150 |
|
|
[考研] 調(diào)劑 +3 | 簡木ChuFront 2026-02-28 | 3/150 |
|