This function searches a numeric value d in dataset vd and returns the value in vref whose index number is the same as d in vd. Interpolation can be employed during this process. This function is usually used to find out the fitted X or Y values after performing the linear or nonlinear fitting, depending on the order of the dataset arguments (See the two examples below).
//If vref contains numeric values,
double Table(vector vd, vector vref, double d[, int option])
//If vref contains strings,
string Table(vector vd, vector<string> vref, double d[, int option])
- is the dataset in which value d is looked up. The values in vd must be placed in ascending order. Otherwise, the function might not return the correct value.
- is the reference vector whose nth value will be return. n is the index number of d within vd.
- is the numeric value to find in vd.
- [optional] integer that specifies how to find out value d. The default value -1 means the function does linear interpolation on vd vs vref and returns the interpolated value. When option = 0, the function searches in vd and finds a value that is equal to d or closest from left. If return value is string, 0 will be used as default since linear interpolation is meaningless to sting. When option = 1, the function finds a value that is equal to d or closest from right. When option = 2, the function finds a value that is equal to d or closest from both sides.
Returns the value in vref whose index number is the same as d in vd.
The following script returns new Y values from a fit curve:
linearfit_Ynew = Table(linearfit_a, linearfit_data1b, linearfit_b)
where linearfit_a is the X fit dataset, linearfit_data1b is the Y fit dataset, and linearfit_b holds the X values for predicting Y values.
The following script returns new X values from a fit curve:
linearfit_Xnew = Table(linearfit_data1b, linearfit_a, linearfit_b)
where linearfit_data1b is the Y fit dataset, linearfit_a is the X fit dataset, and linearfit_b holds the Y values for predicting X values.
The following example shows you how the return value is determined by parameter option
col(a) = data(1,20);
col(b) = data(2,20);
a1 = table(col(a),col(b),4.3,1); //search 4.3 from right
a1 = ; //should return a1=6
a2 = table(col(a),col(b),4.3,0); //search 4.3 from left
a2 = ; //should return a2=5
a3 = table(col(a),col(b),4.3,2); //search 4.3 from both sides
a3 = ; //should return a3=5
a4 = table(col(a),col(b),4.3,-1); //perform linear interpolation on column A and B
a4 = ; //should return a4=5.3