LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read any point from x y arrays

I have 2 arrays x and y these contain coordinates the plot a curve on a xy graph. I need to read the y result at any x point, I thought of using Interpolate function but this will only read in the y array as a linear  and not the curve which is a result of x and y. Any help would be much appreciated, thanks.
0 Kudos
Message 1 of 6
(4,580 Views)
Why not combine the two arrays into one 2D array? Then you can pair up each x value with the associated y value. Once you have the data organized this way, you can index that 2D array to get any x-y pair.
0 Kudos
Message 2 of 6
(4,567 Views)
Are you specifically looking to get the Y value for an X value that is not in your array? If so then you either have to interpolate or create a curvefit that will give you a y=f(x) function. For interpolation the built-in interpolation let you decide what kind of interpolation to use. The shape of your curve and how close together your points are will dictate which method is best.
0 Kudos
Message 3 of 6
(4,562 Views)

Assuming the x-array is sorted low-to-high, you would use "Threshold array" on your x-array and then use the resulting fractional index to use "interpolate 1D array" on the y-array.

 

Here's an very old example:

 

 

 

(original thread from 2004)

 

If your xy data is more complicated (e.g. containing loops), things are no longer simple, because there are possibly zero to multiple y-values for a given x.

Message Edited by altenbach on 05-05-2009 03:03 PM
0 Kudos
Message 4 of 6
(4,553 Views)

altenbach wrote:

Assuming the x-array is sorted low-to-high, you would use "Threshold array"


Corollary: If it's not, the Threshold 1D Array VI (Mathematics -> Interpolation & Extrapolation) could be used as X does not need to be monotonic for that VI, though it's a bit annoying in that you have to feed your X value as an array even if you're just interested in 1 value.

Message Edited by smercurio_fc on 05-05-2009 05:16 PM
0 Kudos
Message 5 of 6
(4,546 Views)
Thanks very much for all your help, the curve is rising and I am  looking for the y at any given x point ( the points in between my coordinates inputted in the arrays). I will try all your suggestions and let you know, thanks again.
0 Kudos
Message 6 of 6
(4,523 Views)