Define a table used to interpolate values from a list of data


table <table name> = <independent variable data>, <dependent variable data>


The TABLE statement allows tabular 1, 2, or 3-dimensional data to be linearly interpolated based on a supplied value of an independent variable (or variables).  The tabular independent and dependent data lists are supplied using array or matrix CONSTANTs.

The TABLE statement essentially gives a name to the table for subsequent lookups, and assigned two or more CONSTANT arrays to the table name.  Lookups (interpolations) of table values are performed by using the TABLE name as if it were a function call, supplying any required independent values as arguments.  The CONSTANT arrays can be treated as any other constant values in CSL; that is, their values may be adjusted prior to runtime without need for recompilation of the model code.

Note that the name of the table must be a valid CSL variable name.


! Dimension the arrays

dimension ageData[10], bwData[10]

! Populate the arrays with data

constant ageData = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

constant bwData  = 0.1, 0.13, 0.17, 2, 3, 5, 8, 11, 15, 20

! Define the table.  First arg after the equal sign is the ind var data

table BodyWeightForAge = ageData, bwData

! This is where table lookups (interpolation) is done

bw = BodyWeightForAge(t)