| 4 | 1/1 | 返回列表 |
| 查看: 912 | 回復(fù): 3 | ||
| 【懸賞金幣】回答本帖問題,作者修竹好衰將贈送您 20 個金幣 | ||
[求助]
初學(xué)用MATLAB求解動力學(xué)模型,但是在非線性二乘法處出現(xiàn)問題 ,麻煩各位大神幫忙看看 已有2人參與
|
||
|
出現(xiàn)的問題是: 錯誤使用 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. 出錯 lsqnonlin (line 262) lsqncommon(funfcn,xCurrent,lb,ub,options,defaultopt,optimgetFlag,caller,... 出錯 kinetic (line 16) lsqnonlin(@fun,k0,lb,ub,[],yexp); 其中反應(yīng)數(shù)據(jù)是引用文件:‘reaction.xls’中每7行為一個反應(yīng)溫度下的各個時間點數(shù)據(jù),總共3個溫度下的數(shù)據(jù),共計21行,已在后面圖片里面顯示 程序: clc clear all; global a b tspan=[0 1 3 5 7 9 11]; %各個反應(yīng)時間點,0h,1h,3h…… yexp=xlsread('reaction.xls') %y的賦值從reaction這個excel文件中調(diào)取 k0=[2*10^8 60000 6.75*10^10 72000 3*10^11 90000]; %每個反應(yīng)速率常數(shù)k所對應(yīng)的A、E,總計6個參數(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) %這個就是擬合的目標函數(shù),得到對應(yīng)最合適的k f=[]; for i=1:3 %對應(yīng)三個溫度下的數(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]; %因為這里r的單位是mol/(g min L)所以需要乘以質(zhì)量 |
鐵桿木蟲 (職業(yè)作家)

| 4 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 293求調(diào)劑 +3 | 是樂渝哇 2026-03-04 | 3/150 |
|
|---|---|---|---|---|
|
[考研] 材料085600 303求調(diào)劑 +6 | 1bygone 2026-03-04 | 6/300 |
|
|
[考研] 085600材料調(diào)劑 總分330 +4 | 池池丶 2026-03-03 | 4/200 |
|
|
[考研] 求調(diào)劑 +4 | 熬夜的貓頭鷹 2026-03-02 | 4/200 |
|
|
[考研] 能動297求調(diào)劑,本科川大 +4 | 邵11 2026-03-04 | 4/200 |
|
|
[考研] 291求調(diào)劑 +3 | 咕嚕咕嚕123123 2026-03-02 | 4/200 |
|
|
[考研] 環(huán)境工程學(xué)碩288求助調(diào)劑 +7 | 多吃億口芝士 2026-03-02 | 7/350 |
|
|
[考研] 266材料化工求調(diào)劑 +3 | 哇塞王帥 2026-03-03 | 3/150 |
|
|
[考研] 0805總分292,求調(diào)劑 +12 | 幻想之殤 2026-03-01 | 12/600 |
|
|
[考研] 291求調(diào)劑 +3 | MuoLuo1312 2026-03-02 | 6/300 |
|
|
[考研] 298求調(diào)劑 +7 | axyz3 2026-02-28 | 8/400 |
|
|
[考研] 290分材料工程085601求調(diào)劑 數(shù)二英一 +8 | llx0610 2026-03-02 | 9/450 |
|
|
[考研] 272求調(diào)劑 +9 | 材紫有化 2026-02-28 | 9/450 |
|
|
[考研] 一志愿華南理工大學(xué)材料與化工326分,求調(diào)劑 +3 | wujinrui1 2026-02-28 | 3/150 |
|
|
[考研] 一志愿鄭大材料學(xué)碩298分,求調(diào)劑 +6 | wsl111 2026-03-01 | 6/300 |
|
|
[考研] 調(diào)劑 +3 | 13853210211 2026-03-02 | 4/200 |
|
|
[基金申請] 成果系統(tǒng)訪問量大,請一小時后再嘗試。---NSFC啥時候好哦,已經(jīng)兩天這樣了 +4 | NSFC2026我來了 2026-02-28 | 4/200 |
|
|
[考研] 化工299分求調(diào)劑 一志愿985落榜 +5 | 嘻嘻(*^ω^*) 2026-03-01 | 5/250 |
|
|
[考博] 26申博 +4 | 想申博! 2026-02-26 | 6/300 |
|
|
[考研] 307求調(diào)劑 +4 | 73372112 2026-02-28 | 6/300 |
|