How to do a non linear fit in MATLAB?
2 views (last 30 days)
Show older comments
Hello!
I am trying to get a and b constants from Van der Waals equation of state using a linear regression in MATLAB but I am not sure how to do that. I have all the PVT data needed.
%VdW
R=8.314;
P=[0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1];
T=[296.35 300.95 305.65 310.35 315.15 319.95 329.45 339.45];
V=[1.1717 1.1749 1.1785 1.1822 1.1861 1.1898 1.1976 1.2056];
P= (R*T)/(V-b) - a/V^2;
Is there a way to get those coefficients using a non linear fit function?
0 Comments
Answers (1)
John D'Errico
on 17 Nov 2020
Edited: John D'Errico
on 17 Nov 2020
Only VERY poorly. Your data is barely sufficient to estimate anything more than a straight line.
R=8.314;
P=[0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1];
T=[296.35 300.95 305.65 310.35 315.15 319.95 329.45 339.45];
V=[1.1717 1.1749 1.1785 1.1822 1.1861 1.1898 1.1976 1.2056];
If we look at your data, P is a constant. T and V are almost perfectly linearly correlated.
plot(T,V,'o')
So there is essentially no information to estimate any nonlinear behavior at all. In order to find the parameter b, for example, b would correspond to a singularity in the curve. Do you see anything singular happening? Do you see any curvature that would convince anyone that this model applies at all?
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!