Using temperature and pressure data to estimate antoine coefficients for glycerol

38 ビュー (過去 30 日間)
Tom Goodland
Tom Goodland 2022 年 1 月 10 日
コメント済み: Star Strider 2022 年 1 月 10 日
I am trying to estimate the antoine coefficients using the nlinfit function form the statistics toolbox, I am getting some errors when trying to run this code, could somebody please help me get this to work and estimate the antoine coefficients i would really appreciate it.
antoine = @(T,p) (log10(p) - A + B/(T+C));
beta0 = [3.93737,1411.531,-200.566];
beta = [A,B,C];
beta = nlinfit(T,p,antoine,beta0);
Error using nlinfit (line 213)
Error evaluating model function '@(T,p)(log10(p)-A+B/(T+C))'.
Error in Temperatureconversion (line 55)
beta = nlinfit(T,p,antoine,beta0);
Caused by:
Error using /
Matrix dimensions must agree.

回答 (2 件)

Star Strider
Star Strider 2022 年 1 月 10 日
Since both variable are present in the objective function equation, nlinfit (or lsqcurvefit) are not really good choices for this.
A regular optimization function (such as fminsearch) would work best. (There are other optionis, however everyone has fminsearch.)
% % % DATA MATRIX MAPPING — T = Tp(:,1), p = Tp(:,2)
Tp = [270:10:320; rand(1,6)].'; % Data Matrix
% % % ANTOINE FUNCTION MAPPING — b(1) = A, b(2) = B, b(3) = C
antoine = @(b,Tp) (log10(Tp(:,2)) - b(1) + b(2)/(Tp(:,1)+b(3)));
beta0 = [3.93737,1411.531,-200.566];
[beta,fv] = fminsearch(@(b)norm(antoine(b,Tp)), beta0);
fprintf('A =\t%10.4f\nB =\t%10.4f\nC =\t%10.4f\nfv =\t%10.4f',[beta,fv])
A = -0.3592 B = 5207.9099 C = 5645.6692 fv = 2.1267
Having the actual data would produce the best results, however the created data demonstrate that the approach works.
.
  11 件のコメント
Torsten
Torsten 2022 年 1 月 10 日
in my physical chemistry labs as an undergraduate our values were often quite good and gave a good fit to the functions with little error
Lucky you !
Star Strider
Star Strider 2022 年 1 月 10 日
We were just compulsive! All of us were doing out best to get into med school, so every little bit helped.

サインインしてコメントする。


Torsten
Torsten 2022 年 1 月 10 日
antoine = @(b,T) 10.^( b(1) + b(2)./(T+b(3)));
beta0 = [3.93737,1411.531,-200.566];
beta = nlinfit(T,p,antoine,beta0)
  5 件のコメント
Torsten
Torsten 2022 年 1 月 10 日
nlinfit starts to evaluate antoine with beta0.
To see what happens, try
vec = antoine(beta0,T)
before you call nlinfit.
Take care that all elements in "vec" are real numbers (no infinity or NaN) by varying beta0.
Tom Goodland
Tom Goodland 2022 年 1 月 10 日
Thanks for the help

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeSolver Outputs and Iterative Display についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by