Inverse hyperbolic fit to data
Ältere Kommentare anzeigen
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
Akzeptierte Antwort
Weitere Antworten (1)
Alan Stevens
am 26 Okt. 2020
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 Kommentar
Alan Stevens
am 26 Okt. 2020
Bearbeitet: Alan Stevens
am 27 Okt. 2020
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

Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!