Contents - Index


LOOKUP

 

The Lookup function is used to retrieve or set a numerical value in a cell of a Lookup Table or a Lookup file (stored in a separate file on disk).  Use the TableValue function to retrieve a value from the Parametric table or the IntegralValue function to retrieve a value from the Integral table.  The Lookup function returns a numerical value.  Use the LOOKUP$ function to return a string. The Lookup function can also be used to set the value of a cell in the Lookup Table as explained below.  The Lookup function can be used with the LookupRow function for interpolation of data in a Lookup Table or file, but the INTERPOLATE command is more convenient for this purpose. 

 

The Lookup function returns a value at a specified row and column from a table of data.  The function normally requires three arguments.  The first argument is a (case-insensitive) string constant or string variable that provides the name of the Lookup table in the Lookup Window or the name of an existing Lookup file. The string constant must be enclosed within single quote marks.  Lookup table names appear on the tabs at the top of the Lookup Table Window.  The next two arguments are constants or variables that provide the row and column to access in the specified Lookup table or Lookup file.  The function returns the value at the specified row and column. 

 

The column may be indicated in several different ways.  Most simply, the column may be entered by supplying the column number.  In this case, it is not necessary for the column to be an integer.  Interpolation will be provided automatically for non-integer column numbers.  Alternatively, the column may be entered with a string variable or string constant set to the name of the column shown in the column header.  The string constant must be enclosed within single quote marks. 

 

Example:

     Row=2

     H=Lookup('Lookup 1', Row, 'X')      {­returns the value in row 2 of the column name X in the Lookup 1 table}

 

The Lookup function will return the value in the Lookup Table at the specified row and column.   The row and column do not have to be integer values.  Linear interpolation will be applied as necessary if the row or column are non-integers. For example:

 

Lookup('myTable', 2,3.5) will return a value which is midway between the values on the second row in the third and fourth columns for the Lookup table named 'myTable'.  

 

Use the Lookup$ command to return a string rather than a numerical value.

 

Lookup files are data files that reside on disk rather than in the Lookup table window.  EES recognizes Lookup files,identified by the filename extensions of .LKT, .CSV, .TXT and .DAT.  If a filename extension is not provided, EES assumes the binary form for the Lookup file and internally adds .LKT.  See Lookup file Formats for additional information.

 

Lookup('C:\abc\CopperK.LKT', R, 'Temp')  will return the value found in row R and the column named Temp in file C:\abc\CopperK.LKT.  The Lookup file must be saved using the Save Lookup Table command in EES.  The file name and column name could have been provided with string variables, e.g., Lookup(File$,R,T$) where File$ must be set to the desired file name and T$ must be set to the name of the column.

 

If the specified row or column is less than one, the value in the first row or column will be returned. Similarly, if the row or column is greater than the number of rows and columns in the Lookup Table, the value in the last row or column will be returned.

 

The Lookup function can be used with the LookupCol and LookupRow LookupRow to provide interpolated values of user-supplied tabular information.

 

(Note:  use a semicolon instead of a comma as the list separator when using the European numerical format).

 

The Lookup function can also be used to set the value of a cell in the Lookup Table window when it is used on the left-hand side of an equation in an internal Function or Procedure.  For example, the following function sets the values in the first column of the Lookup table named 'Lookup 1' to sequential integers beginning with 101.

 

function SetLookup(NRows)

   i:=0

   repeat

      i:=i+1

      Lookup('Lookup 1',i,1)=100+i

   until (i>=NRows)

   SetLookup:=1; {­must return a value}

end

 

Note that variables (but not algebraic expressions) can be used as row and column arguments to the Lookup function when it is used in this manner.  However, their values must be within the range of the currently defined Lookup Table.  Note the $CopyToLookup directive provides a simpler manner of moving data into a Lookup table.  

 

Setting Lookup Table values provides an alternative way to pass information to Functions, Procedures, Modules and Subprograms.  Since the Lookup Table is accessible to all EES statements, array information can be stored in the Lookup Table and used where it is needed.  This capability can also be used to chain EES programs for sequential operation by having one EES program save the Lookup Table in a Lookup file which is then used by the next EES program which is opened.  The $OpenLookup and $SaveLookup directives and the Link button that can be placed on the Diagram window facilitate the chaining process.  

 

The $Export directive also provides a means of copying results from EES into a file on disk.  The $Export is more convenient when data are to be read into another application.

 

See also:

LOOKUPROW  

LOOKUPCOL

INTERPOLATE  

LOOKUP$

INTERPOLATE1

INTERPOLATE2

INTERPOLATE2DM

Mathematical functions

$CopyToLookup