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.
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.
01-28-2011 09:49 AM
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!
01-28-2011 09:55 AM - edited 01-28-2011 10:00 AM
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.
01-28-2011 10:05 AM
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!
01-28-2011 10:23 AM
Thanks a bunch! The VI you posted does exactly what I was looking for.
01-28-2011 10:24 AM
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.
01-28-2011 01:20 PM
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.
01-28-2011 01:40 PM
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.
01-28-2011 01:45 PM
@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.
01-28-2011 02:55 PM
Is the relationship linear? Maybe you could use a formula instead of a lookup table? It would eliminate interpolation.
01-28-2011 03:08 PM
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.