LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interpolate linear equations with third variable

Solved!
Go to solution

I have sets of calibration data of time stamp in one column and an associated value in the other. The data pairs are used to create a linear 'fit' of the form Y=MX+C and on the whole quite close.

 

These data 'pairs' are then repeated for a value determined by a third variable so in example attached there are now 6 linear equations in play.

 

What I need to do is be able to input the x value of the linear equation as one variable and the third variable to arrive at a value for Y. The interpolation then being between the 6 linear equations.

 

I have attached the vi being used to find the slope (m) and intercept (c) of the linear equations for data set on vi.

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 1 of 6
(2,199 Views)
Solution
Accepted by topic author jack1

You basically have a plane in 2D, so all you need is to do a fit to a 2D polynomial.

 

I would rename the variables so you have points in space (xyz) where:

  • x is a value from columns, 0, 2, 4, 6...
  • y is the value based on N of your loop
  • z is a corresponding value from columns 1, 3, 5, etc.)

Find the coefficients of the formula of a plane

 

Z(x,y) = A + Bx + Cy

 

This is most easily done using general linear fit. You could even add higher terms if needed. There are old forum examples that can guide you in the right direction.

 

Once you have the coefficients, you can calculate z for and x,y pair.

 

Attached is a simple code skeleton (LV2014). You can redefine what's x, y, and, z of course as needed. It was not entirely clear what your independent variables are.  (my subVI to create the H matrix was posted very long ago here)

 

 

0 Kudos
Message 2 of 6
(2,157 Views)

Thanks for your help with this. 

 

This is a problem you helped me out with a while back using Interpolation but pointed out that the restrictions would be the limits set by calibration, which has proved to be the case. You also mentioned the use of polynomial equations and it has been found that the system response for a given pressure is quite linear hence my earlier post with y=mx+c for each  pressure (series 1:6 on graph). 

 

The two external variables are the required mass (grams) and pressure which affects the amount dispensed. The result is the time required to dispense the required amount of mass (grams). I have changed your program slightly to swap the y and z columns and also obtain fraction index for x from the calibration pressures. 

 

I need to carry out some testing on this and also read the other posts your have recommended to try and understand how the code is working.

 

Thanks again,

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
Download All
0 Kudos
Message 3 of 6
(2,145 Views)
Solution
Accepted by topic author jack1

I now vaguely remember our old discussion. (I'll look at your code later, currently not near a suitable computer).

 

In the code I attached earlier, you could easily go to quadratic order for a much better fit. Do you know the estimated error in your data? Is the error mostly in Z or also in the other two directions?

0 Kudos
Message 4 of 6
(2,130 Views)

I am currently getting the calibration data repeated because I have noticed some of the values obtained could not be correct because they indicate a fall in dispensed material for increase in pressure on a few occasions so some error could be due to the calibration data.

 

I have only done cursory checks this afternoon and found some error but will spend time on it tomorrow to determine error range, where it occurs and if its in the calibration values or software algorithim.

 

Thanks again for your help,

 

 

 

 

 

 

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 5 of 6
(2,123 Views)

Thanks for your help and sorry for delay in posting but have attached version using quadratic equation which seems to work much better and replicates the original calibration plots both within the calibration values and those that are calculated.

Labview Version 8.5
Labview Version 8.6
Labview Version 2014
0 Kudos
Message 6 of 6
(2,081 Views)