DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I code a 2-D look-up table in a DIadem script?

Based on two existing Diadem variables, what is the syntax for doing a linear interpolation inside a 6 x 5 table to calculate a third value that is a function of both of the first two variables?  This would be similar to doing a horizontal and a vertical lookup in Excel.
0 Kudos
Message 1 of 5
(5,071 Views)

Hi aviatrix,

Where is the lookup table in DIAdem?  Is it an invisible variable that you repeatedly reference, or is it a series of Channels in the Data Portal, or do you have the choice as to how to architect the lookup table?  The programming approach for these two cases is very different.

Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 2 of 5
(5,052 Views)
Hi Brad,

Sorry I wasn't more specific.  I've copied the entire table below; I can reference in any manner that would make sense; its entries are constants.  First I'd like to check the value of a Diadem variable, 'efficiency', to see if it's between 0.2 and 0.7 (the first row of the table).  If it is outside that range, then the new variable 'bypass' should be set to zero.  Then I'd like to check the Diadem variable "utility" to be within 5 and 50 inclusive (the first column of the table).  If it is outside the range, then again bypass should equal zero.  If efficiency and utility are both within range, then I'd like to linearly interpolate between the values of the table (based on efficiency and utility) to calculate bypass.



0.2 0.3 0.4 0.5 0.6 0.7
5 1.5 2 3 3.5 4.5 6
8 1.8 2.9 4.2 5 10.9 15.3
10 2 3.5 5 7 14 21.5
30 4 8 17 31 40 80
50 5.5 16 17 31 40 80


Thank you for your help - aviatrix.
0 Kudos
Message 3 of 5
(5,043 Views)

Hi aviatrix,

I went ahead and built an example for you of how DIAdem can tackle a lookup table.  Note than in the example it loads the raw lookup table values into the first Group, creates a high-definition lookup table in the second Group, then executes 3 individual requests to lookup interpolated values for arbitrary [X,Y] pairs.  The function "GetInterpValue()" that I created returns a VBScript Null if the X or Y value is out of range.

In a real application, you would want to create the high-definition lookup table Group one time, then leave it for as long as you will need to reference it.  You do NOT need to recreate the high-definition lookup table Group multiple times for multiple lookup requests.

Brad Turpin
DIAdem Product Support Engineer
National Instruments

Message 4 of 5
(5,022 Views)
 
Thanks Brad.  That works and it's exactly what we were trying to do.
0 Kudos
Message 5 of 5
(4,983 Views)