Inverse hyperbolic fit to data

2 ビュー (過去 30 日間)
deltaruby
deltaruby 2020 年 10 月 26 日
編集済み: Alan Stevens 2020 年 10 月 27 日
Hi, i'm trying to fit the model (P+a)(V+b)=(Po+a)*b to some data in MATLAB (where a and b are constants and Po is the value of P at V=0), I'm just wondering how you do this.
My data is:
P = [5 7.5 10 12.5 15 17.5 20 25 30 35 40 45 50 55 60 65];
V = [32.89 26.48 22.28 19.16 17.25 14.97 13.40 10.66 9.38 7.88 6.66 5.89 4.79 4.49 2.43 1.37];
Thanks

採用された回答

Mathieu NOE
Mathieu NOE 2020 年 10 月 26 日
hi
below the code that solve your problem using fminsearch
P = [5 7.5 10 12.5 15 17.5 20 25 30 35 40 45 50 55 60 65];
V = [32.89 26.48 22.28 19.16 17.25 14.97 13.40 10.66 9.38 7.88 6.66 5.89 4.79 4.49 2.43 1.37];
% fminsearch optimization loop
fun = @(x)norm((P+x(1)).*(V+x(2))-(x(3)+x(1))*x(2)); %a = x(1), b=x(2), Po = x(3)
x0 = [0, 0, 0];
X = fminsearch(fun,x0);
a = X(1)
b=X(2)
Po = X(3)
% check on plot :
Vfit=((Po+a)*b)./(P+a) - b;
figure(1), plot(P,V,'b',P,Vfit,'r');grid
legend('experimental','fit');

その他の回答 (1 件)

Alan Stevens
Alan Stevens 2020 年 10 月 26 日
Here's an alternative, with V as the independent variable and P as the dependent one:
% Data
P = [5 7.5 10 12.5 15 17.5 20 25 30 35 40 45 50 55 60 65]';
V = [32.89 26.48 22.28 19.16 17.25 14.97 13.40 10.66 9.38 7.88 6.66 5.89 4.79 4.49 2.43 1.37]';
% (P + a)(V + b) = (P0 + a)*b
% P*V +a*V + b*P + a*b = P0*b + a*b
% V*a + P*b - P0b = -P*V
% M*X = C where M = [V P -1]; X = [a; b; P0b]; C = -P.*V;
M = [V P -ones(size(V))];
C = -P.*V;
X = M\C;
a = X(1);
b = X(2);
P0 = X(3)/b;
disp('a b P0')
disp([a b P0])
p = (P0 + a)*b./(V + b) - a;
plot(V,P,'o',V,p,'*-'),grid
xlabel('V'),ylabel('P')
legend('data','curve fit')
This produces
  1 件のコメント
Alan Stevens
Alan Stevens 2020 年 10 月 26 日
編集済み: Alan Stevens 2020 年 10 月 27 日
With V as the independent variable
p = (P0 + a)*b./(V + b) - a;
plot(V,P,'o',V,p,'*-')
should now be replaced by
v = (P0 + a)*b./(P + a) - b;
plot(P,V,'o',P,v,'*-')
with corresponding label changes.
The result should now look like

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

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

タグ

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by