Previous Page | Next Page

Language Reference

INSERT Function

INSERT( x, y, row<, column> ) ;

The INSERT function inserts one matrix inside another.

The arguments to the INSERT function are as follows:

x

is the target matrix. It can be either numeric or character.

y

is the matrix to be inserted into the target. It can be either numeric or character, depending on the type of the target matrix.

row

is the row where the insertion is to be made.

column

is the column where the insertion is to be made.

The INSERT function returns the result of inserting the matrix y inside the matrix x at the place specified by the row and column arguments. This is done by splitting x either horizontally or vertically before the row or column specified and concatenating y between the two pieces. Thus, if x has rows and columns, row can range from 0 to and column can range from 0 to .

It is not possible to insert in both dimensions simultaneously, so either row or column must be 0, but not both. The column argument is optional and defaults to 0. Also, the matrices must conform in the dimension in which they are joined.

The following statements show two examples of the INSERT function. Figure 23.132 shows that the matrix c is the result of inserting matrix b prior to the second row of matrix a. The matrix d is the result of inserting matrix b after the second column of matrix a.

a = {1 2, 3 4};
b = {5 6, 7 8};
c = insert(a, b, 2, 0);
d = insert(a, b, 0, 3);
print c, d;

Figure 23.132 Inserted Matrices
c
1 2
5 6
7 8
3 4

d
1 2 5 6
3 4 7 8

Previous Page | Next Page | Top of Page