Go to Post you must do whats best for the company...not yourself. - Greg Perkins [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-02-2012, 18:48
Itamar's Avatar
Itamar Itamar is offline
Registered User
FRC #1943 (NeatTeam) & FRC #4590 (GreenBlitz)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Israel
Posts: 83
Itamar is an unknown quantity at this point
Calculating a value from a collection of given points on the graph?

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.
Reply With Quote
  #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,100
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
  #3   Spotlight this post!  
Unread 12-02-2012, 19:04
Itamar's Avatar
Itamar Itamar is offline
Registered User
FRC #1943 (NeatTeam) & FRC #4590 (GreenBlitz)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Israel
Posts: 83
Itamar is an unknown quantity at this point
Re: Calculating a value from a collection of given points on the graph?

Quote:
Originally Posted by Ether View Post
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.
Funny, those are actually exactly the two ideas which my friend and I thought of. To be honest, I was convinced LabVIEW is designed to solve these kind of problems with quick and easy-to-use VIs. We will probably go with the second solution. However, are you sure there isn't a VI that already does this? (not out of lazyness, it's just very surprising)
Reply With Quote
  #4   Spotlight this post!  
Unread 12-02-2012, 19:07
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,100
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
However, are you sure there isn't a VI that already does this? (not out of lazyness, it's just very surprising)
I didn't say there isn't a VI that does that.

I said I don't know. I'm not a seasoned LabVIEW user.

Reply With Quote
  #5   Spotlight this post!  
Unread 12-02-2012, 20:20
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Calculating a value from a collection of given points on the graph?

You're looking for the Interpolate 1D function. It's in the Mathematics>Interpolation & Extrapolation function palette. You can select from many different methods by which it can do its job; the detailed help for the function does a good job of explaining what each method does.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 22:08.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi