From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Look up x & y values in a table and output the corresponding number?

I'm trying to take a temperature input and an elevation input from the FP and find the corresponding number in a table.  For example, if I had a temp of 15 degrees and the elevation is 900 feet the resulting output would be 1325.  I've looked a several examples of lookup tables and arrays in the forum, but none of them look like they would be useful for what I'm wanting to do or atleast I can't figure out how I could use them.  I'm sure it isn't too complicated, but I've only gotten as far as my lacking experience can get me.  Any help with this would be greatly appreciated.

 

Thanks!

0 Kudos
Message 1 of 18
(4,013 Views)

I assume that your temperature and altitude values are assigned as the column and row headers on the table. If that is the case you can use a property nodes to read column and row headers/names. Search each of these arrays for the desired value. Your search will give you the row and column indices you need to index the 2D array for the value.

 

I have attched a very basic example. You will need to put logic in to determine what to do if you do not have an exact match.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 18
(4,005 Views)

I'm not sure how to assign the row and column header values to the table.  Would I use a properties node to do that as well?

 

Thanks for the quick response!

0 Kudos
Message 3 of 18
(3,999 Views)

Thanks a bunch!  The VI you posted does exactly what I was looking for.

0 Kudos
Message 4 of 18
(3,991 Views)

Yes if yu want to do that programmatically. You can also just type them into the table. You would need to save the values as the default values if you do this.

 

On the property node you can right click on the property and change it to a write property.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 5 of 18
(3,990 Views)

Is there a way I could have it interpolate for input values that aren't in the table headers?  I'm sure this is a stretch, but I thought I'd ask.

0 Kudos
Message 6 of 18
(3,973 Views)

If you are referring to the lookup choosing a value when your search parameters are not explicitly defined in the column or row headers you would have to implement your own search algorithm in a for loop. You could also look at the various VIs in the math libraries (Mathematics->Interporlation and Extrapolation) if you want to output values that are interpolated based on the table.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 7 of 18
(3,964 Views)

 


@dirtpics wrote:

Is there a way I could have it interpolate for input values that aren't in the table headers?  I'm sure this is a stretch, but I thought I'd ask.


 

Easy.

TakeoffDistance.png

Message 8 of 18
(3,959 Views)

Is the relationship linear?  Maybe you could use a formula instead of a lookup table?  It would eliminate interpolation.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 9 of 18
(3,945 Views)

No, it isn't linear unfortunately.  I tried the VI from the post above, but can't get it to spit out anything.  It's fine until the interpolation function, then it only kicks out zero.  Any thoughts?

 

I don't necessarily need things to be interpolated for it to work, but it sure would make it alot more convenient to use.

 

Thanks for all your replies.  Atleast it got me going again.

0 Kudos
Message 10 of 18
(3,938 Views)