COLEXTRACT

Purpose:

Extracts a portion of each column of a table.

Syntax:

COLEXTRACT(a, start, length, offset, allcols)

a

-

A table.

start

-

A series. A list of integer starting points.

length

-

A series. A list of integers specifying the number of points to be extracted from each column. -1 implies extract to the end of the column

offset

-

Optional. A series. A list of real values specifying the X offset of the resulting columns. Defaults to the X value of the starting points.

allcols

-

Optional. An integer, apply start, length and offset to all columns one at a time.

0:

apply start, length and offset to subsequent columns (default)

1:

apply start, length and offset to all columns one at a time.

Returns:

A table.

Example:

a = {{1, 2, 3},

     {4, 5, 6}, 

     {7, 8, 9}, 

     {3, 4, 5}} 

 

b = colextract(a, {1, 2, 3}, {3, 2, -1})

 

b == {{1, 5, 9},

      {4, 8, 5}, 

      {7}} 

 

Here COLEXTRACT implies the following:

 

Starting at the first point, extract 3 points from column 1.

Starting at the second point, extract 2 points from column 2.

Starting at the third point, extract to the end of column 3.

Example:

a = {{1, 2, 3},

     {4, 5, 6}, 

     {7, 8, 9}, 

     {3, 4, 5}} 

 

b = colextract(a, {1, 2, 3}, {3, 2, -1}, 1)

 

Now b contains the table:

 

  1     4     7     2     5     8     3     6     9

  4     7     3     5     8     4     6     9     5

  7                 8                 9           

 

 

Same as the first example except COLEXTRACT is applied to all columns using the input parameters, Here COLEXTRACT implies the following:

 

Starting at the first point, extract 3 points from column 1.

Starting at the second point, extract 2 points from column 1.

Starting at the third point, extract to the end of column 1.

 

Starting at the first point, extract 3 points from column 2.

Starting at the second point, extract 2 points from column 2.

Starting at the third point, extract to the end of column 2.

 

Starting at the first point, extract 3 points from column 3.

Starting at the second point, extract 2 points from column 3.

Starting at the third point, extract to the end of column 3.

Example:

W1: integ(gnorm(100,1))

W2: integ(gnorm(200, .1))

W3: ravel(W1, W2)

W4: transpose(colmaxidx(W3))

W5: colextract(W3, W4-10, ones(numcols(W3), 1)*20+1)

W6: W1;overp(col(w5, 1))

W7: W2;overp(col(W5, 2))

 

image\colextrpic.png

 

W6 and W7 highlight in light red a 20 point window around the maximum values of the original series in W1 and W2.

Remarks:

If start is negative, zeros are prepended to the result. If the number of points to extract is greater than the series or table length, the result is padded with zeros.

 

If allcols is 1, the parameters start, length and offset are applied to each column, one at a time.

 

See XCOLEXTRACT to extract portion of each column of a table based on X values.

See Also:

COL

COLPAIRWISE

CONCAT

CUT

EXTRACT

EXTRACTWIN

RAVEL

SEREXTRACT

XCOLEXTRACT

XEXTRACT