MxSetBlock
- sets values in the rectangular block of matrix cells

Matrix functions
(AFL 4.10)


SYNTAX MxSetBlock( matrix, startrow, endrow, startcol, endcol, values = 0 )
RETURNS Matrix
FUNCTION Sets values in the rectangular block of cells (rows in the range startrow..endrow and columns in the range startcol..endcol inclusive).

This allows to fill entire or partial rows, columns and all other kind of rectangular areas in the matrix with user specified data. Row and column numbers are zero based.

If values parameter is scalar, all cells in specified block are filled with that value. If values parameter is an array, cells in the block are filled from left to right and from top to bottom with consecutive values taken from that array. If there are more cells in the block than values in the array, the array item counter wraps around to zero and starts taking values from the beginning

Note: the function creates new matrix as a result (so source matrix is unaffected unless you do the assignment of the result back to the original variable)

EXAMPLE // Example 1:
// Create a matrix 6x6
// and fill 4x4 interior (except edges with consecutively increasing numbers)

y = Matrix( 6, 6, 0 );
y = MxSetBlock( y, 1, 4, 1, 4, Cum(1));
printf("Matrix y ");
printf( MxToString( y ) );

// Example 2:
// Create a matrix 2 rows x 20 columns and fill rows 0, 1 with first 20 values of Close and RSI(5) arrays respectively

z = Matrix( 2, 20, 0 );
// first row
z = MxSetBlock( z, 0, 0, 0, 19, Close );
// second row
z = MxSetBlock( z, 1, 1, 0, 19, RSI( 5 ) );
printf("Matrix z ");
printf( MxToString( z ) );
SEE ALSO Matrix() function , MxGetSize() function , MxToString() function

References:

The MxSetBlock function is used in the following formulas in AFL on-line library:

More information:

Updated on-line reference