07-09-2017 10:02 PM
when we get data from the measurement ,we always meet the situation that the result value Z is related to 2 Independent Variable ,actually it likes 3D surface .
the formula always like :Z=F(X,Y).
I checked the polynomial fit express vi on labview , but i still can not find a solution to built an complicated user-defined polynomial and get the coefficient.
for example ,i can defined a simple polynomial and let the X,Y,Z to fit as this polynomial ,then get coefficients.
this picture shows my defined polynomial Z=c0+c1*X+C2*X^2+C3*X^3+C4*X^4+C5*X^5+C00*Y+C01*Y^2+C02*Y^3
but the coefficient come form the every different degree formula ,then if i want to define a polynomial like :
p0=c0;
p1=c1*X;
p2=c2*X*X;
p4=c4*X*X*X*X;
p5=c5*X*X*X*X*X;
p6=c6*X*X*X*X*X*X;
F1=(p0+p1+p2+p4+p5+p6+p7);
F2=c00*Y+c01*Y*Y+c02*Y*Y*Y;
F3=(c10*Y+c11*Y*Y+c12*Y*Y*Y)*F1*F1;
Z=F1+F2+F3;
HOW CAN I TO DEFINE this polynomial and fit as least square method ?
Thanks ,
Solved! Go to Solution.
07-09-2017 10:04 PM
i really need to get the coefficient after fitting !
07-09-2017 11:40 PM
Can you attach your actual VI?
07-10-2017 02:22 AM
thank you for your reply , actually i learned this method from here ,named:"9P interpolacija v2.vi" ,i also attached it ,i downloaded it from here .
it's very normal to calculate the value by least square method in industry ,for example :when you measure the concentration of liquid via the speed of sound principle ,the concentration are related to the speed of sound and temperature .so,the Z is concentration and X is speed of sound ,Y is temperature .
sometimes ,you need to find a best model of surface to describe this relation .so you need to test different model of polynomial .
that is the reason why i need the coefficient .
thanks again
07-10-2017 08:27 AM
Your VI does not contain any data. Please attach some reasonable xyz data to be fit.
(I cannot open your VI on english Windows unless I rename the file. Please use regular file names).
There are probably better ways to create the H Matrix than with a formula node. That 9P example looks overly complicated. But yes, you'll get the least square fit and coefficients out of it at the end.
07-10-2017 10:38 PM
thank you for you reply
here i make a modification on my vi ,thank you for your help kindly .
07-11-2017 03:26 PM - edited 07-13-2017 11:07 AM
07-13-2017 07:59 AM
Thank you very very much ,this is really good solution for this kind of formula .i start to understanding the matrix in labview via this example ,thanks again.
i try to draw a 3D surface by this data ,but the surface looks very strange !
07-13-2017 09:25 AM
The H matrix won't give you any interesting surface. What you need to do is generate a xy grid that covers a similar range (in x and y) as the input data and is spaced sufficiently to show all the details, then calculate Z for each grid point. Overlay it over the real data.
07-13-2017 10:34 AM - edited 07-13-2017 10:49 AM
I quickly modified one of my ancient VIs to show the general procedure. See if this works for you.
(This is using the old actvieX 3D graphs. Should be easy to adapt to the new versions)
(Note that SVD has problems. You need to use a different algorithm, such as LU decomposition)