# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

## Re: Finding best fit equation for two knows variables

Hi altenbach,

Where to change the order of polynomial in attached VI?

in My VI some of paramters are in languaae I cannot understand though?

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.

Message 11 of 34
(372 Views)

## Re: Finding best fit equation for two knows variables

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???

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.

I have a look at it tomorrow. LabVIEW Champion. It all comes together in GCentral What does "Engineering Redefined" mean??
Message 12 of 34
(365 Views)

## Re: Finding best fit equation for two knows variables

Do you have a link to a publication or website that explains the model? Whatever you have currently implemented is not a polynomial. Which terms are you trying to leave out to see if the fit is still sufficient? LabVIEW Champion. It all comes together in GCentral What does "Engineering Redefined" mean??
Message 13 of 34
(353 Views)

## Re: Finding best fit equation for two knows variables

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.

Temperature values are entered in kelvin instead of celsius

sensor:  OTP-638D2_datasheet(R(0) and application(0-50)

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.

(Tried attaching files here,but some error)

Message 14 of 34
(343 Views)

## Re: Finding best fit equation for two knows variables

@Vindhyachal.Takniki wrote:

A) Here is datasheet and values of sensor. Page 6 mentions the formula.

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? LabVIEW Champion. It all comes together in GCentral What does "Engineering Redefined" mean??
Message 15 of 34
(334 Views)

## Re: Finding best fit equation for two knows variables

@Vindhyachal.Takniki wrote:

In my case error margin of less than +-0.5 is acceptable.

A first order 2D polynomial  is within ±0.15, well within your specs (3 coeficients).

Z = -4.19E-1 -8.69E-2 * x +9.78E-2 * y.

A second order 2D polynomial is within ±0.012 (see image below. Green is difference between data and fit):

(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)

A third order will be within ±0.005. I guess all you need is a first order 2D polynomial.

Attached is a quick draft. See if you understand it. I wasn't kidding when I said the code fits on a postcard. 🙂

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.  LabVIEW Champion. It all comes together in GCentral What does "Engineering Redefined" mean??
Message 16 of 34
(326 Views)

## Re: Finding best fit equation for two knows variables

Hi,

I have attached the updated Vi with correct info.  First column is "z", second col is "x" & third column is "y"

I tried 3 order equation, which shows acceptable min & max values.

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

I think the "Best Fit formula" has wrong coeff multiplication? Is it so?

void get_value(float32_t x , float32_t y)
{
float32_t x2 = x * x;
float32_t x3 = x2 * x;

float32_t y2 = y * y;
float32_t y3 = y2 * y;

float32_t xy = x * y;
float32_t x2y = xy * x;
float32_t xy2 = xy * y;
float32_t z;

z = (-0.856405103370700971000000f)
+(1.063190618820774920000000f * x)
+(14.209914285379092300000000f * y)
+(-0.001525431973314523430000f * x2)
+(-0.110425437452562752000000f * xy)
+(-0.561650715977711323000000f * y2)
+(0.000112007671458926302000f * x3)
+(0.000361024027398679400000f * x2y)
+(0.002619887991367739200000f * xy2)
+(-0.009204815618802958400000f * y3);

}

Message 17 of 34
(284 Views)

## Re: Finding best fit equation for two knows variables

@Vindhyachal.Takniki wrote:

I have attached the updated Vi with correct info.  First column is "z", second col is "x" & third column is "y"

You have not attached anything. It seems that the column designation I guessed is correct.

@Vindhyachal.Takniki wrote:

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

You are not showing much of any math. Who wrote the C code? What is a "LabVIEW error graph"?

@Vindhyachal.Takniki wrote:

I think the "Best Fit formula" has wrong coeff multiplication? Is it so?

What do you consider "right"? LabVIEW Champion. It all comes together in GCentral What does "Engineering Redefined" mean??
Message 18 of 34
(274 Views)

## Re: Finding best fit equation for two knows variables

Sorry PFA the VI.

I have written C code.

Error in VI shows +-0.02 error.

Somehow when I put coordinates in C code they dont give correct results.

Message 19 of 34
(255 Views)

## Re: Finding best fit equation for two knows variables

This is the LabVIEW forum, so let's focus on the LabVIEW solution.

If c code does not give the correct result, you need to ask elsewhere to find what could be wrong with it. LabVIEW Champion. It all comes together in GCentral What does "Engineering Redefined" mean??
Message 20 of 34
(250 Views)