MATLAB: How to find the coefficients of a polynomial equation for fit the curve in MATLAB

coefficientsfit dataMATLABpolynomial

hello. my polynomial equation is ( V)=c0+c1*T+c2*(t^2)-c3*P-c4*P*T i want use data for find c0 ,c1, …c4 coefficients (i want fit data with this equation)
my p,v,t data is
100000 , 0.956 , 19.4
100000 , 0.9717 , 71.1
10000000 , 0.959 , 41.8
80000000, 0.9725 , 161 …
thank you.

Best Answer

if "p" and "t" are both independant variables then your problem is in the form of "y=f(x,z)" or "v=f(p,t)".
x=[
19.4
71.1
41.8
161
180
]; % t
y=[
100000
100000
10000000
80000000
100000000
]; % p
z=[
0.956
0.9717
0.959
0.9725
0.9999
]; % z
sf = fit([y, x],z,'poly21')
plot(sf,[y,x],z)
look at command window,
sf(x,y) = p00 + p10*x + p01*y + p20*x^2 + p11*x*y
V(t,p) = c0 +c1*T - c3*P +c2*(t^2) - c4*T*P
by comparing you will understant that:
c0=p00
c1=p10
c3=-p01
c2=p20
c4=-p11;