3.5.1.1.2 Col

Col function refers to the dataset in a worksheet column, to a cell in the column, or to the column headers. There are four function forms depending on what is refered to. In either form, Col function can be used either on the left side, or on the right side of an assignment.

Note: In the col(colNameOrNum) function, colNumVariable is always interpreted as a value. However, it is different from Wcol(colNumExpression) function, where colNumExpression is interpreted as an expression to specify the column number.


Col(colNameOrNum)

The col(colNameOrNum) function can be used either on the left side, or on the right side of an assignment. When it is in the left side, it receives a datasets (i.e., a vector, a series of data values) to be assigned. When it is in the right side, it returns the dataset which has the column name colName in the active worksheet. The column name can be either the "short name" or the "long name". If the name is surrounded by double-quotes("), it is regarded as a long name. When column name is NOT quoted, then the short name takes precedence. Not only the column name, but also the column number can be specified. For example, if column A is the first column in the worksheet, col(1) and col(A) both return the dataset in column A.

Function Form:

 Col(index), or Col(name)

Col(colNameOrNum)[rowNum]

The col(colNameNum)[rowNum] function can be used on either the left or right side of an assignment. When it is in the left side, it receives a numerical value to be assigned. When it is in the right side, it returns a numeric value of a single dataset element. The column name (or column number) is indicated in parentheses, while the row number is included in brackets. The column name can be either the "short name" or the "long name". If the name is surrounded by double-quates("), it is regarded as a long name. When column name is NOT quoted, then the short name takes precedence. Origin returns the value of the cell specified by the given row and column numbers.

Function Form:

 Col(index)[rowNum], or Col(name)[rowNum]
Note: If the column has been set as categorical, Origin will return the category index of the cell specified by the given row and column numbers.

Col(colNameOrNum)[rowNum]$

The col(colNameOrNum)[rowNum]$ function can be used on either the left or right side of an assignment. When it is in the left side, it receives a string value to be assigned. When it is in the right side, it returns a string value of a single dataset element. Indicate the column name or column number in parentheses and the row number in brackets. The column name can be either the "short name" or the "long name". If the name is surrounded by double-quates("), it is regarded as a long name. When column name is NOT quoted, then the short name takes precedence. Origin returns the text of the cell specified by the given row and column numbers.

Function Form:

 Col(index)[rowNum]$, or Col(name)[rowNum]$

Col(colNameOrNum)[colHdrType]$

The col(colNameOrNum)[colHdrType]$ function accesses the column headers (e.g., Long Name, Units, Comment, Parameters, Sampling Interval and user-defined headers), and it has similar syntax to Col(colNameOrNum)[rowNum]$ .

Function Form:

 Col(index)[colHdrType]$, or Col(name)[colHdrType]$

Here, colHdrType is one of the column label row characters.

Example

Examples for Col(...)

  • Example 1
In the following example, if column C (specified at the left side of the assignment) does not exist, Origin creates a new column. (New! in Origin 8)
col(C) = (1+col(A)) / (1-col(B));

Examples for Col(...)[rowNum]

  • Example 1
In the following example, the variable myVar is assigned the value in the third row of column B.
myVar=col(B)[3];
  • Example 2
In the following example, the fourth cell of column B is assigned the value 9.
col(B)[4]=9;


Examples for Col(...)[rowNum]$

In the following example, the variable %W is assigned the text element in the third row of column A.
%W = col(A)[3]$;


Examples for Col(...)[colHdrType]$

  • Example 1
col(2)[L]$=my full name;  // set long name
%a=col(2)[U]$;  // get units
%a=col(2)[D2]$; // get the 2nd user defined header

See Also