10-09-2018 05:32 PM
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.
Solved! Go to Solution.
10-10-2018 05:19 AM
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:
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)
10-10-2018 07:03 AM
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.
10-10-2018 11:15 AM
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?
10-10-2018 12:49 PM
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,
11-04-2018 02:32 PM
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.