View Single Post
  #2   Spotlight this post!  
Unread 12-02-2012, 18:56
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,065
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Calculating a value from a collection of given points on the graph?

Quote:
Originally Posted by Itamar View Post
Hey. I need a function that does something like this: I give it a collection of (X, Y) points on my graph, plus another X point. Then the output is the Y coordinates in the given X. Something like this:



The blue points are given, and then I give another X value and get it's Y value. I went through a lot of the mathmatics functions and found nothing that performs this action, so it would be really helpful if anyone could help me find the right VI to do this.

thanks,
Itamar.
There are at least two classes of methods to do this.

Method1: Lookup Table.

You put the known X,Y points in a table (array) in your code, and you sort the points so that the X values are in order. Then you take your unknown X and search the table, comparing it to the X values in the table, until you find the two points in the table which it is between. Then you perform a calculation called "interpolation" to find the unknown Y value. This might sound difficult but it's really quite straightforward.

Method2: Mathematical Model

The most common mathematical model is a polynomial. You take all the given data and you try to find a polynomial which fits the data. Once you've got the polynomial, you just plug in your unknown X and compute the associated Y value. You can find this polynomial very easily using Excel spreadsheet using the "trendline" feature. Just type your X,Y data into Excel in to two columns, then graph it, then use the trendline feature to find a polynomial of chosen degree.


I'm not a LabVIEW guru and I don't have LabVIEW installed here, but I believe LabVIEW supports lookup tables. It wouldn't surprise me if it also has the ability to calculate the coefficients of a polynomial model for you as well. Try searching the LabVIEW help for those words.

Last edited by Ether : 12-02-2012 at 18:59.
Reply With Quote