# Vensim Help

 VECTOR LOOKUP(vec,x,xmin,xmax,mode) Performs a LOOKUP on a VECTOR

Allows the specification of a nonlinear function by specifying the y values in vec, which must be a subscripted variable, and giving the minimum and maximum values for x in xmin and xmax. The specified range for x is broken up into n equal intervals where n is one less then the length of the vector vec. If vec is a multidimensional array then the length used is the number of elements in the last subscript. This function should always be called with the first element of vec as shown in the example.

The function VECTOR LOOKUP encompasses the behavior of all the regular lookup function with the results of using the function determined by the value of mode which should be an integer between 0 and 9.

0 a normal lookup function determining y from x.

1 the equivalent of LOOKUP AREA

2 the equivalent of  LOOKUP BACKWARD

3 the equivalent of LOOKUP EXTRAPOLATE

4 the equivalent of LOOKUP FORWARD

5 the equivalent of LOOKUP INVERT

6 the equivalent of LOOKUP SLOPE

7 the equivalent of LOOKUP AREA with extrapolation

8 the equivalent of LOOKUP INVERT with extrapolation

9 the equivalent of LOOKUP SLOPE with extrapolation

Note that 7,8 and 9 do not have equivalent functions using regular Lookups. Also note that for 1 and 7 the area returned is the area from xmin. If you want to get the area between two values use

Area for LV = VECTOR LOOKUP(LV[s1],xend,xmin,xmax,1) –

VECTOR LOOKUP(LV[s1],xstart,xmin,xmax,1)

Also note that in mode 7 if x is less than xmin the, assuming vec is all positive, a negative number will be returned. This means that the above formula for area between two points is still valid.

The variable vec can be constant or time varying (for example a Level, Auxiliary or even Data), but  must be subscripted. This allows you to create lookups with shapes that change over time and allows for a variety of flexible ways of specifying functions. For example, you can specify a 2 dimensional Lookup function using

XDim : (x1-x3)

YDim : (y1-y5)

xmin = 0

xmax = 10

ymin = 0

ymax = 100

lookup vals[XDim,YDim] = 1.1,1.2,1.3,1.4,1.5;

2.1,2,2.2.3,2.4,2.5;

3.1,3.2,3.3,3.4,3.5;

output = VECTOR LOOKUP(xslice[x1],x,xmin,xmax,0)

xslice[XDim]=VECTOR LOOKUP(lookup vals[XDim,y1],y,ymin,ymax,0)

Units: VECTOR LOOKUP(units,units1,units1,units1,dmnl) --> units

The mode expression should be dimensionless and x, xmin and xmax must have the same units. This is appropriate for the most common uses but it is likely that when mode is 1, 5 7 or 8 you will need to use units multipliers, or leave everything dimensionless, to pass units checking.

If you call this function with vec a scalar or with an element that is not the first element on the vector’s last subscript an error will occur during simulation.

NOTES :

1. VECTOR LOOKUP does not give any warning messages when the input is outside of the specified range.

2. VECTOR LOOKUP should only be used on full vectors, do not use it on a subranged vector.

Availability: Professional and DSS only.