topic Re: Finding best fit equation for two knows variables in LabVIEW
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4065663#M1167514
<P>Hi Altenbach,</P>
<P> </P>
<P>Can u suggest some way to it?</P>
<P>Or some direction where to proceed to it?</P>Wed, 08 Jul 2020 10:25:59 GMTVindhyachal.Takniki2020-07-08T10:25:59ZFinding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061313#M1165718
<P>I have some chart in excel, where I get two values from measurment, lets say Va and Vb.</P>
<P>Now I need to find the best fit equation for it?</P>
<P>can labview do it?</P>Sun, 21 Jun 2020 04:25:19 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061313#M1165718Vindhyachal.Takniki2020-06-21T04:25:19ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061317#M1165720
<P>Edit: wha ti wanted to know equation would be </P>
<P>C = some equation of (A,B)</P>
<P> </P>
<P>A,B, & C values I know, want to find equation where I can put A&B values and get C from it.</P>Sun, 21 Jun 2020 04:40:06 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061317#M1165720Vindhyachal.Takniki2020-06-21T04:40:06ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061322#M1165722
<P>If you have only two points, you can fit basically anything to it.</P>
<P> </P>
<P>The most common solution (and perhaps what you're asking for) is a linear fit - a straight line that goes through your two points with the equation "y = mx + c".</P>
<P>To solve for that equation, you'd want to write your results as follows:</P>
<P> </P>
<P>Va = m * Xa (whatever your input is at measurement a) + c</P>
<P>Vb = (m * Xb) + c</P>
<P> </P>
<P>Vb - Va = (m * Xa) + c - (m * Xb) - c = m * (Xa - Xb).</P>
<P>Since you know Xa and Xb and Va and Vb, you can calculate "m" from this.</P>
<P> </P>
<P>Then, substitute into one of your starting equations to find c.</P>
<P>Now you have a linear equation that goes through your two points.</P>
<P> </P>
<P>Note that this has nothing to do with LabVIEW - it's just algebra.</P>
<P> </P>
<P>Implementing it in LabVIEW can be done with the nodes on the Numeric palette (i.e. subtract, multiply, etc).</P>
<P>You can also use a graph and something like a For loop to plot a line that highlights your solution.</P>
<P> </P>
<P>For more complicated assumed equations, you can use more advanced tools like the Fitting VIs. However, for an equation of greater than linear complexity you'll need more than 2 points (results) to be able to solve it.</P>Sun, 21 Jun 2020 05:06:41 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061322#M1165722cbutcher2020-06-21T05:06:41ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061341#M1165726
<P>i have around 200 value sets where i know C,A,B</P>
<P>Need to form equaton, its not linear fit.</P>
<P>would be something like this I guess, but not sure. So what labview function for this?</P>
<P> </P>
<DIV id="tinyMceEditorVindhyachal.Takniki_0" class="mceNonEditable lia-copypaste-placeholder"> </DIV>
<DIV id="tinyMceEditorVindhyachal.Takniki_1" class="mceNonEditable lia-copypaste-placeholder"> </DIV>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ddd.png" style="width: 278px;"><img src="https://forums.ni.com/t5/image/serverpage/image-id/269182i0BFDF704861A52CD/image-size/large?v=v2&px=999" role="button" title="ddd.png" alt="ddd.png" /></span></P>
<P> </P>Sun, 21 Jun 2020 10:05:21 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061341#M1165726Vindhyachal.Takniki2020-06-21T10:05:21ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061344#M1165728
<P>I think you probably want to take a look at this VI - it can be used generally to solve this kind of fitting problem: <A href="https://zone.ni.com/reference/en-XX/help/371361R-01/gmath/nonlinear_curve_fit/" target="_self">Nonlinear Curve Fit</A>. </P>
<P>This page will give more information about its usage: <A href="https://zone.ni.com/reference/en-XX/help/371361R-01/gmath/levenberg_marquardt_theory/" target="_self">Creating the Formula String or Fitting Model to Specify a Nonlinear Function</A>. </P>
<P> </P>
<P>Christian Altenbach gave a presentation about the use of this function (amongst others) that can be found here: <A href="https://forums.ni.com/t5/Nonlinear-Fitting/NiWeek-2017-Presentation-Solving-the-inverse-problem-with/gpm-p/3650248" target="_self">slides</A>. Unfortunately I can't find a video anymore...</P>
<P> </P>Sun, 21 Jun 2020 10:43:53 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061344#M1165728cbutcher2020-06-21T10:43:53ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061372#M1165747
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P>i have around 200 value sets where i know C,A,B</P>
<P>Need to form equaton, its not linear fit.</P>
<P>would be something like this I guess, but not sure. So what labview function for this?</P>
<P> </P>
<DIV id="tinyMceEditorVindhyachal.Takniki_0" class="mceNonEditable lia-copypaste-placeholder"> </DIV>
<DIV id="tinyMceEditorVindhyachal.Takniki_1" class="mceNonEditable lia-copypaste-placeholder"> </DIV>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ddd.png" style="width: 430px;"><img src="https://forums.ni.com/t5/image/serverpage/image-id/269182i0BFDF704861A52CD/image-dimensions/430x113?v=v2" width="430" height="113" role="button" title="ddd.png" alt="ddd.png" /></span></P>
<HR /></BLOCKQUOTE>
<P>If you are not "sure", you need to fully research the problem until you are. Nobody can solve a "not sure" problem.</P>
<P> </P>
<P>Your question makes no sense because your function shown does not even contain any C, A, or B.</P>
<P> </P>
<UL>
<LI>What are the model parameters?</LI>
<LI>What is/are the independent variable(s)?</LI>
<LI>What is the dependent variable?</LI>
</UL>
<P> </P>
<P>How does the set of 200 C, A, B values look like? What does the data represent? What are you trying to learn from it?</P>
<P> </P>Sun, 21 Jun 2020 16:57:12 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061372#M1165747altenbach2020-06-21T16:57:12ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061373#M1165748
<P>For simplicity, let's redefine C=z, A=x, B=y, so basically you have 200 scattered (xyz) points in space. If these points form some kind of unique plane where for any arbitrary [x,y] a "z" can be estimated, you can fit it to a model that describes this plane. It could be a higher order 2D polynomial or any other model based on an underlying theory. The plane is then defined by the set of model parameters (a0, a1, a2, aN) And for each arbitrary x,y points, a unique Z can be found based on the best fit parameters and a given [x,y]. Do the x,y point form a regular grid?</P>
<P> </P>
<P><A href="https://forums.ni.com/t5/Nonlinear-Fitting/Forum-Examples-for-2D-Fitting/gpm-p/3492975#M3" target="_blank" rel="noopener">Start reading here</A>.</P>
<P> </P>
<P> </P>
<P>OTOH, if the model is discrete and only exists at the given x,y points, you could use a map (requires LabVIEW 2019 or newer!) serving as a lookup table. The key would be a 2D array containing x and y and the value would be z. (Be careful with any key datatype where equal comparisons are questionable (e.g. DBL))</P>Sun, 21 Jun 2020 17:15:09 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061373#M1165748altenbach2020-06-21T17:15:09ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061828#M1165932
<P>Thanks @<SPAN class="login-bold"><A id="link_4" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://forums.ni.com/t5/user/viewprofilepage/user-id/7614" target="_self">altenbach</A> .</SPAN></P>
<P><SPAN class="login-bold">Sorted the issue</SPAN></P>Tue, 23 Jun 2020 07:23:13 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061828#M1165932Vindhyachal.Takniki2020-06-23T07:23:13ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061829#M1165933
<P>Can it be used to make equation where:</P>
<P>1. A= fun(x,y,z) where 4 paramters are known and need to make equation</P>
<P> </P>
<P>2. Also in above equation generated is quite complex for low power MCU computation, any method where lesser order polynomial can be made. </P>
<P>In my case error margin of less than +-0.5 is acceptable.</P>
<P> </P>
<P> </P>Tue, 23 Jun 2020 07:42:36 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061829#M1165933Vindhyachal.Takniki2020-06-23T07:42:36ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061942#M1165988
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P>Can it be used to make equation where:</P>
<P>1. A= fun(x,y,z) where 4 paramters are known and need to make equation</P>
<HR /></BLOCKQUOTE>
<P>Yes, it can be expanded to any number of dimensions. The general technique stays exactly the same.</P>
<P> </P>
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P>2. Also in above equation generated is quite complex for low power MCU computation, any method where lesser order polynomial can be made. </P>
<P>In my case error margin of less than +-0.5 is acceptable.</P>
<HR /></BLOCKQUOTE>
<P>A polynomial in any number of dimensions is not "complex". A polynomial is generic and only defined by the number of terms. Start with low order, the increase the order until the result is withing the desired margins. If it still does not fit with a ~third order, maybe you need to create a model based on some theory.</P>
<P> </P>
<P>It really depends on the data ±0.5 is excellent if the data is in the millions, but very poor if the data is in the nano or micro range.</P>
<P> </P>Tue, 23 Jun 2020 16:03:52 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4061942#M1165988altenbach2020-06-23T16:03:52ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062688#M1166270
<P>Hi altenbach,</P>
<P> </P>
<P>Where to change the order of polynomial in attached VI?</P>
<P>in My VI some of paramters are in languaae I cannot understand though?</P>
<P> </P>
<P>What I want to do now keep on change order of polynimial on see the erro graph, and chose best fit for what minium polynomial order gives acceptable error.</P>Fri, 26 Jun 2020 02:37:28 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062688#M1166270Vindhyachal.Takniki2020-06-26T02:37:28ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062733#M1166297
<P>Who wrote this VI? I cannot read the labels either (unicode?) but the entire program is just a mess. Most of the FOR loops can be replaced by a single "index array"! Why such a convoluted formula node???</P>
<P> </P>
<P>Sorry, I am on a laptop. No way to work with such an oversized VI. I am sure written properly it could fit on a postcard.</P>
<P> </P>
<P>I have a look at it tomorrow.</P>Fri, 26 Jun 2020 07:20:36 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062733#M1166297altenbach2020-06-26T07:20:36ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062754#M1166307
<P>Do you have a link to a publication or website that explains the model? Whatever you have currently implemented is <STRONG>not a polynomial</STRONG>. Which terms are you trying to leave out to see if the fit is still sufficient?</P>Fri, 26 Jun 2020 08:38:56 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062754#M1166307altenbach2020-06-26T08:38:56ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062825#M1166340
<P>A) Here is datasheet and values of sensor. Page 6 mentions the formula. But somehow it doesnt fit. We have value of Vtp, Tsensor, need to calculate value of Tobject.</P>
<P>Temperature values are entered in kelvin instead of celsius</P>
<P>sensor: OTP-638D2_datasheet(R(0) and application(0-50)</P>
<P> </P>
<P> </P>
<P>B) Had a word with another manufactuere about the formula, from TE sensor, here is his reply in all the files are in here,image file has also reply.</P>
<P>(Tried attaching files here,but some error)</P>
<P><A href="https://drive.google.com/drive/folders/1y3CeuI2JJiHkSXrAeQXknYa-iJVJ3zLk?usp=sharing" target="_blank">https://drive.google.com/drive/folders/1y3CeuI2JJiHkSXrAeQXknYa-iJVJ3zLk?usp=sharing</A></P>
<P> </P>
<P> </P>Fri, 26 Jun 2020 14:01:22 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062825#M1166340Vindhyachal.Takniki2020-06-26T14:01:22ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062860#M1166354
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P>A) Here is datasheet and values of sensor. Page 6 mentions the formula.</P>
<HR /></BLOCKQUOTE>
<P>Your attachment only has one page. There is no page 6 Whatever is in the documentation has absolutely no resemblance to the formulas in the VI you attached earlier. Do you just want to parameterize the 2D V-T table on page 10-11 of the other document? Where did the data on your VI come from?</P>Fri, 26 Jun 2020 16:12:11 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062860#M1166354altenbach2020-06-26T16:12:11ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062901#M1166373
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P> </P>
<P>In my case error margin of less than +-0.5 is acceptable.</P>
<HR /></BLOCKQUOTE>
<P>A first order 2D polynomial is within ±0.15, well within your specs (3 coeficients).</P>
<P> </P>
<P> Z = -4.19E-1 -8.69E-2 * x +9.78E-2 * y.</P>
<P> </P>
<P>A second order 2D polynomial is within ±0.012 (see image below. Green is difference between data and fit):</P>
<P> </P>
<P> (6 terms: Z = +1.70E-1 -6.83E-2 * x +5.93E-2 * y -3.18E-4 * x^2 -6.54E-5 * xy +5.01E-4 * y^2) </P>
<P> </P>
<P>A third order will be within ±0.005. I guess all you need is a first order 2D polynomial.</P>
<P> </P>
<P>Attached is a quick draft. See if you understand it. I wasn't kidding when I said the code fits on a postcard. <span class="lia-unicode-emoji" title=":slightly_smiling_face:">🙂</span></P>
<P>Of course I wasn't sure what's x and y, so modify as needed. Also note that the data forms a regular integer grid, so it could be represented as a 2D array and reshaped for fitting. No need to drag along x and y if done correctly.</P>
<P> </P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2Dpoly.png" style="width: 999px;"><img src="https://forums.ni.com/t5/image/serverpage/image-id/269432i3382161743CFA00B/image-size/large?v=v2&px=999" role="button" title="2Dpoly.png" alt="2Dpoly.png" /></span></P>Fri, 26 Jun 2020 19:13:10 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062901#M1166373altenbach2020-06-26T19:13:10ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062947#M1166381
<P>Hi,</P>
<P>Thanks for reply.</P>
<P>I have attached the updated Vi with correct info. First column is "z", second col is "x" & third column is "y"</P>
<P> </P>
<P>I tried 3 order equation, which shows acceptable min & max values.</P>
<P> </P>
<P>But when i tried its equation in C code, it gives weird results. Though in labview error graphs shows no error. Below is my c code</P>
<P> </P>
<P>I think the "Best Fit formula" has wrong coeff multiplication? Is it so?</P>
<P> </P>
<P>void get_value(float32_t x , float32_t y) <BR />{<BR />float32_t x2 = x * x;<BR />float32_t x3 = x2 * x;</P>
<P>float32_t y2 = y * y;<BR />float32_t y3 = y2 * y;<BR /><BR />float32_t xy = x * y;<BR />float32_t x2y = xy * x;<BR />float32_t xy2 = xy * y;<BR />float32_t z;<BR /><BR /><BR />z = (-0.856405103370700971000000f)<BR />+(1.063190618820774920000000f * x)<BR />+(14.209914285379092300000000f * y)<BR />+(-0.001525431973314523430000f * x2)<BR />+(-0.110425437452562752000000f * xy) <BR />+(-0.561650715977711323000000f * y2) <BR />+(0.000112007671458926302000f * x3)<BR />+(0.000361024027398679400000f * x2y) <BR />+(0.002619887991367739200000f * xy2)<BR />+(-0.009204815618802958400000f * y3); <BR /><BR />}</P>Sat, 27 Jun 2020 08:24:13 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062947#M1166381Vindhyachal.Takniki2020-06-27T08:24:13ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062977#M1166398
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P> </P>
<P>I have attached the updated Vi with correct info. First column is "z", second col is "x" & third column is "y"</P>
<P> </P>
<HR /></BLOCKQUOTE>
<P>You have not attached anything. It seems that the column designation I guessed is correct.</P>
<P> </P>
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P>But when i tried its equation in C code, it gives weird results. Though in labview error graphs shows no error. Below is my c code</P>
<HR /></BLOCKQUOTE>
<P>You are not showing much of any math. Who wrote the C code? What is a "LabVIEW error graph"?</P>
<P> </P>
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P>I think the "Best Fit formula" has wrong coeff multiplication? Is it so?</P>
<HR /></BLOCKQUOTE>
<P>What do you consider "right"?</P>
<P> </P>
<P> </P>Sat, 27 Jun 2020 15:42:56 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4062977#M1166398altenbach2020-06-27T15:42:56ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063039#M1166435
<P>Sorry PFA the VI.</P>
<P>I have written C code.</P>
<P> </P>
<P>Error in VI shows +-0.02 error.</P>
<P>Somehow when I put coordinates in C code they dont give correct results.</P>Sun, 28 Jun 2020 04:34:48 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063039#M1166435Vindhyachal.Takniki2020-06-28T04:34:48ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063042#M1166437
<P>This is the LabVIEW forum, so let's focus on the LabVIEW solution.</P>
<P> </P>
<P>If c code does not give the correct result, you need to ask elsewhere to find what could be wrong with it.</P>Sun, 28 Jun 2020 06:10:09 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063042#M1166437altenbach2020-06-28T06:10:09ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063043#M1166438
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P>Sorry PFA the VI.</P>
<P> </P>
<HR /></BLOCKQUOTE>
<P>You change the order of columns. Now the last column is z so you need to rewire the columns coming out of the index array so they are correct. The last column now seems to be Z..</P>Sun, 28 Jun 2020 06:18:34 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063043#M1166438altenbach2020-06-28T06:18:34ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063044#M1166439
<P>After wiring correctly, I get the following for the max deviation:</P>
<P> </P>
<P>Polynomial Order. dev=x</P>
<P> </P>
<OL>
<LI>dev=0.18</LI>
<LI>dev=0.018</LI>
<LI>dev=0.007</LI>
<LI>dev=0.006</LI>
<LI>dev=0.004</LI>
</OL>
<P> </P>Sun, 28 Jun 2020 06:34:21 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063044#M1166439altenbach2020-06-28T06:34:21ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063046#M1166441
<P>Sir,</P>
<P> </P>
<P>It simple multiplications of variables only which isnot giving right results.</P>
<P>Labview gives almost zero error +-0.02 which is very good</P>
<P> </P>
<P>I am saying is that there could be error in selection which degree of plunomoial like x or y or x2y to multiplied with which coefficient. It could be error.</P>
<P> </P>
<P>Its not even c code, its simple mathematical equation which is giving error.</P>
<P>So must be mismatch </P>Sun, 28 Jun 2020 07:14:55 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063046#M1166441Vindhyachal.Takniki2020-06-28T07:14:55ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063047#M1166442
<P>Oh didnt read your last two replies.</P>
<P>Yes i had changed the columns of data, didnt changed any wiring though, since I changed the columns only.</P>
<P> </P>
<P>Its not even a c code, its simple math equation.</P>
<P>What I suspect we are multiplying wrong coefficent orders with wrong poly factor.</P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P>void get_value(float32_t x , float32_t y)<BR />{<BR />float32_t x2 = x * x;<BR />float32_t x3 = x2 * x;</P>
<P>float32_t y2 = y * y;<BR />float32_t y3 = y2 * y;<BR /><BR />float32_t xy = x * y;<BR />float32_t x2y = xy * x;<BR />float32_t xy2 = xy * y;<BR />float32_t z;<BR /><BR /><BR />z = (-0.856405103370700971000000f)<BR />+(1.063190618820774920000000f * x)<BR />+(14.209914285379092300000000f * y)<BR />+(-0.001525431973314523430000f * x2)<BR />+(-0.110425437452562752000000f * xy)<BR />+(-0.561650715977711323000000f * y2)<BR />+(0.000112007671458926302000f * x3)<BR />+(0.000361024027398679400000f * x2y)<BR />+(0.002619887991367739200000f * xy2)<BR />+(-0.009204815618802958400000f * y3);<BR /><BR />}</P>Sun, 28 Jun 2020 07:20:55 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063047#M1166442Vindhyachal.Takniki2020-06-28T07:20:55ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063070#M1166450
<P>I don't understand why you keep attaching the same files. Once is enough. If you attach a new and different file, give it a new name. Also please exclusively use zip archives. Not everybody has tools that can open rar files.</P>
<P> </P>
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:
<P>Yes i had changed the columns of data, didnt changed any wiring though, since I changed the columns only.</P>
<HR /></BLOCKQUOTE>
<P>Well, if you reassign the columns, you also need to change the wiring.</P>
<P> </P>
<BLOCKQUOTE><HR /><LI-USER login="Vindhyachal.Takniki" uid="318026"></LI-USER> wrote:<BR />
<P><BR />z = (-0.856405103370700971000000f)<BR />+(1.063190618820774920000000f * x)<BR />+(14.209914285379092300000000f * y)<BR />+(-0.001525431973314523430000f * x2)<BR />+(-0.110425437452562752000000f * xy)<BR />+(-0.561650715977711323000000f * y2)<BR />+(0.000112007671458926302000f * x3)<BR />+(0.000361024027398679400000f * x2y)<BR />+(0.002619887991367739200000f * xy2)<BR />+(-0.009204815618802958400000f * y3);</P>
<HR /></BLOCKQUOTE>
<P>These numbers have no resemblance to the best fit. Where do they come from? I think a handful of significant digits is probably sufficient.</P>
<P> </P>Sun, 28 Jun 2020 14:43:39 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063070#M1166450altenbach2020-06-28T14:43:39ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063551#M1166618
<P>Thanks @altenbach,</P>
<P>A) Able to sort out the issue. Now I got the equation which is +-0.1 error. This is acceptable</P>
<P>Able to make equation for around 1500 data set and they work best for me</P>
<P> </P>
<P>B) Now I want to extend it to further entire range of sensor data roughly 38000 data-set.</P>
<P>1st column is "z". Second column is "x" . Third column is "y"</P>
<P>Z = Fun(x,y)</P>
<P> </P>
<P>x is temperature measured</P>
<P>y is voltage measured</P>
<P> </P>
<P> </P>
<P>C) PFA two files:</P>
<P>1. test RI_2Dpolynomial.vi</P>
<P>2. test RI_2Dpolynomial-set2.vi</P>
<P> </P>
<P>Only diff is dataset representation. Dataset is same though</P>
<P>1. First file have dataset arranged in increasing order of temperature("x") i.e 0 to 50 and then again 0 to 50 and so on</P>
<P>2. Second have dataset in which "x" is kept same for 751 readings and then "x" is incremented by 1 and so on</P>
<P> </P>
<P>Both datasets are same. </P>
<P>Reason is I think since not good fit model comes out, it seems like need to break data into multiple set points and make equation for each dataset.</P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>Tue, 30 Jun 2020 13:02:38 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063551#M1166618Vindhyachal.Takniki2020-06-30T13:02:38ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063767#M1166717
<P>Hi <SPAN>@altenbach,</SPAN></P>
<P> </P>
<P><SPAN>Can u tell?</SPAN></P>
<P><SPAN>How to do it?</SPAN></P>
<P><SPAN>I have tried to break data into three parts and see equation, but still its very large error fit.</SPAN></P>Wed, 01 Jul 2020 06:09:43 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063767#M1166717Vindhyachal.Takniki2020-07-01T06:09:43ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063887#M1166764
<P>You still have xyz wired incorrectly.</P>Wed, 01 Jul 2020 13:34:19 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063887#M1166764altenbach2020-07-01T13:34:19ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063954#M1166792
<P>Once you wire xyz correctly, both arrangement of the dataset give 100% identical results!</P>
<P>You really need to try to understand how all this works. This has been going on for over a week now !:</P>
<P> </P>
<P><span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="altenbach_0-1593620381254.png" style="width: 999px;"><img src="https://forums.ni.com/t5/image/serverpage/image-id/269669iE6F06BE619796FF5/image-size/large?v=v2&px=999" role="button" title="altenbach_0-1593620381254.png" alt="altenbach_0-1593620381254.png" /></span></P>
<P> </P>Wed, 01 Jul 2020 16:22:39 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4063954#M1166792altenbach2020-07-01T16:22:39ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4064089#M1166865
<P>Hi @<A id="link_0" class="lia-link-navigation lia-page-link lia-user-name-link" href="https://forums.ni.com/t5/user/viewprofilepage/user-id/7614" target="_self"><SPAN class="login-bold">altenbach</SPAN></A></P>
<P><SPAN class="login-bold">Thanks for reply.</SPAN></P>
<P> </P>
<P><SPAN class="login-bold">I think we are taking correct wiring. I think there is some confusion, due to me in first two replies, as i had confused VI.</SPAN></P>
<P><SPAN class="login-bold">PFA the data set, this is dataset we want to fit.</SPAN></P>
<P> </P>
<P><SPAN class="login-bold">Column 1 is Z<BR />Column 2 is x<BR />Column 3 is y</SPAN></P>
<P><SPAN class="login-bold">We want to make equation with Z=Fun(x,y).</SPAN></P>
<P> </P>
<P> </P>
<P> </P>Thu, 02 Jul 2020 05:58:13 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4064089#M1166865Vindhyachal.Takniki2020-07-02T05:58:13ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4064610#M1167050
<P>Hi @altenbach,</P>
<P>1. I tried to break the equation into muliple parts for z. Since my z range is -50 to 700. These are parts I have gets where 6th order polynomial fits.<BR />-50 to 61<BR />61 to 192<BR />192 to 278<BR />278 to 346<BR />346 to 401<BR />401 to 446<BR />446 to 477<BR />477 to 599<BR />599 to 668<BR />668 to 700</P>
<P><BR />2. "test RI_2Dpolynomial-set2_break.vi" is used where small sets of data is taken to see in which regions it shows polynonimal fit. One at time. First I tried on dataset of -50 to 61 ,then ran VI again for next data set and so on. Max error allowed is +-0.0999.</P>
<P> </P>
<P>3. Then I ran test on all available data-points for -50 to 61 range and saw the results. It shows a poly fit of 6th order. Need to check for rest of changes though.</P>
<P> </P>
<P>4. Still is there any better method which you can suggest? It may not poly fit always, may be any other non-linear fit ?</P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>
<P> </P>Fri, 03 Jul 2020 15:28:19 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4064610#M1167050Vindhyachal.Takniki2020-07-03T15:28:19ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4064624#M1167058
<P>Yes, x and y (2nd and 3rd column) also form a reasonable grid and can be fit. However the fit does not look that great and might need higher terms, at least in one of the dimension..Of course a 2D polynomial is just a generic model and you could of course implement any other theory and use nonlinear fitting instead.</P>Fri, 03 Jul 2020 16:32:39 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4064624#M1167058altenbach2020-07-03T16:32:39ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4065663#M1167514
<P>Hi Altenbach,</P>
<P> </P>
<P>Can u suggest some way to it?</P>
<P>Or some direction where to proceed to it?</P>Wed, 08 Jul 2020 10:25:59 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4065663#M1167514Vindhyachal.Takniki2020-07-08T10:25:59ZRe: Finding best fit equation for two knows variables
https://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4066139#M1167681
<P>Move up?</P>Thu, 09 Jul 2020 11:33:54 GMThttps://forums.ni.com/t5/LabVIEW/Finding-best-fit-equation-for-two-knows-variables/m-p/4066139#M1167681Vindhyachal.Takniki2020-07-09T11:33:54Z