| 5 | 1/1 | 返回列表 |
| 查看: 917 | 回復(fù): 3 | ||
| 【懸賞金幣】回答本帖問題,作者修竹好衰將贈送您 20 個金幣 | ||
| 當(dāng)前只顯示滿足指定條件的回帖,點(diǎn)擊這里查看本話題的所有回帖 | ||
[求助]
初學(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)溫度下的各個時間點(diǎn)數(shù)據(jù),總共3個溫度下的數(shù)據(jù),共計21行,已在后面圖片里面顯示 程序: clc clear all; global a b tspan=[0 1 3 5 7 9 11]; %各個反應(yīng)時間點(diǎn),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) %這個就是擬合的目標(biāo)函數(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]; %因?yàn)檫@里r的單位是mol/(g min L)所以需要乘以質(zhì)量 |

鐵桿木蟲 (職業(yè)作家)
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 售瀆SCI文章,我:8⊙ 55 1⊙ 54。備注【⊙=0】 +3 | ipys00zm58 2026-03-06 | 4/200 |
|
|---|---|---|---|---|
|
[考研] 308求調(diào)劑 +7 | 倘若起風(fēng)了呢 2026-03-05 | 9/450 |
|
|
[考研] 303求調(diào)劑 +5 | forgman95 2026-03-05 | 7/350 |
|
|
[考研] 306求調(diào)劑 +7 | Bahati 2026-03-05 | 7/350 |
|
|
[考研] 080500材料科學(xué)與工程 +13 | 202114020319 2026-03-03 | 13/650 |
|
|
[考研] 283求調(diào)劑 +10 | 鹿沫笙 2026-03-02 | 11/550 |
|
|
[考研] 085701環(huán)境工程 求調(diào)劑 +7 | xiiiia 2026-03-04 | 7/350 |
|
|
[考研] 322分 085600求調(diào)劑,有互聯(lián)網(wǎng)+國金及主持省級大創(chuàng)經(jīng)歷 +6 | 熊境喆 2026-03-04 | 6/300 |
|
|
[考研] 266求調(diào)劑 +7 | 哇塞王帥 2026-03-03 | 7/350 |
|
|
[考研] 0855機(jī)械工程324求調(diào)劑 +3 | 鄭SK 2026-03-02 | 7/350 |
|
|
[考研] 材料專碩346求調(diào)劑 +3 | 旺一下 2026-03-04 | 3/150 |
|
|
[考研] 085600 材料與化工 298 +14 | 小西笑嘻嘻 2026-03-03 | 14/700 |
|
|
[考研] 085600求調(diào)劑 +4 | LRZZZZZZ 2026-03-02 | 6/300 |
|
|
[考研] 085602化學(xué)工程350,調(diào)劑,有沒有211的 +5 | 利好利好. 2026-03-02 | 9/450 |
|
|
[考研] 清華大學(xué) 材料與化工 353分求調(diào)劑 +5 | awaystay 2026-03-02 | 6/300 |
|
|
[考研] 338求調(diào)劑 +5 | 18162027187 2026-03-02 | 6/300 |
|
|
[考研] 【2026 碩士調(diào)劑】課題組 招收調(diào)劑生 +3 | 考研版棒棒 2026-03-02 | 5/250 |
|
|
[考研] 272求調(diào)劑 +9 | 材紫有化 2026-02-28 | 9/450 |
|
|
[考研] 一志愿華南理工大學(xué)材料與化工326分,求調(diào)劑 +3 | wujinrui1 2026-02-28 | 3/150 |
|
|
[考研] 284求調(diào)劑 +10 | 天下熯 2026-02-28 | 11/550 |
|