# Polynomial Fitting of 3 variables

조회 수: 18(최근 30일)
Eliraz Nahum 11 Oct 2019
편집: Eliraz Nahum 11 Oct 2019
Hello everyone,
I would like to know if there is any option of fitting a polynomial function to a set of n points.
I mean supplying (x1,y1,z1,f(x1,y1,z1)), (x2,y2,z2,f(x2,y2,z2)), ............., (xn,yn,zn,f(xn,yn,zn)) and getting:
P(x,y,z)=a1*(x^k)+a2*(y^k)+a3*(z^k)+....+const
Thanks!

로그인 to comment.

### 채택된 답변

John D'Errico 11 Oct 2019
편집: John D'Errico 11 Oct 2019
1. Ensure you have sufficient data. I.e., significantly more data points than you have coefficients to estimate.
2. Make sure the data is itself sufficient. People frequently do not realize their data does not support estimation of all those coefficients. For example, it is a good idea for the data to essentially fill the region they will be building that model from. Do NOT think you can estimate that model using data that lies itself on a curve in the XYZ space, or even on a surface. That will fail miserably.
3. Make sure you will not have numerical problems in the fit. This usually means that if your data (X,Y,Z) are numbers of alarge magnitude, then you will need to scale them in such a way that raising them to powers will not in itself be a problem, in terms of double precision arithmetic. You can improve the conditioning of the problem even more by centering the variables. That means to have each of x,y,z being variables that live on the domain [-1,1]. Polyfit itself has such an option to help you do this automatically, but polyfitn does not. Such is life, and it is not difficult to do.
4. Do not even fantasize that just because a linear model works ok, and a quadratic model gives a better fit, that a complete 10th order polynomial has a chance in hell of being a good idea.

로그인 to comment.

### 추가 답변(1개)

Eliraz Nahum 11 Oct 2019
편집: Eliraz Nahum 11 Oct 2019
Since you were so generous and your answer is incredibly informative, I am sure you may answer this as well.
I have 2 functions I would like to have a prolynomial approximation for (I attached a photo).
what is marked in yellow is constant.
the variables are those who written in green - D, H, L.
how can I know if a polynomial fit is quite accurate in this case, and if yes - what is the adequate power.
thanks a lot!

#### 댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

R2019a

Translated by