2.8.3.1 Basic Matrix Object Operation

A matrixsheet can have multiple matrix objects, which share the same dimensions. A matrix object is analogous to a worksheet column and can be added or deleted, etc. The following sections provide some practical examples on the basic operations of matrix object.

Add or Insert Matrix Object

It allows to set the number of matrix objects in the matrixsheet by using wks.nmats, so to add matrix objects. Also, the method wks.addcol() can be used to add a matrix object.

// Set the number of matrix objects in the matrixsheet to 5
wks.nmats = 5;
// Add a new matrix object to a matrixsheet
wks.addCol();
// Add a named matrix object to a matrixsheet
wks.addCol(Channel2);

By default, the 1st matrix object in matrixsheet is the current matrix object, you can use the wks.col property. And the method wks.insert() will insert matrix object before the current matrix object.

// Create a new matrixbook, and show image thumbnails
newbook mat:=1;
matrix -it 1;

// Insert a matrix object before the 1st one in the active matrixsheet
wks.insert();

// Set the 2nd matrix object to be the current one
wks.col = 2;

// Insert a matrix object before the 2nd one
wks.insert();

Activate Matrix Object

To activate a matrix object in the active matrixsheet, the wks.active is available.

// Create a new matrixbook
newbook mat:=1;

// Add two more matrix objects to the active matrixsheet
wks.addCol();
wks.addCol();

// Show image thumbnails
matrix -it 1;

// Activate the second matrix object
wks.active = 2;

Switch Between Image Mode and Data Mode

The matrix command has provided the option for switching between image mode and data mode of the matrix object. Only the active matrix object appears in the matrixsheet.

matrix -ii 1;  // Show image mode
matrix -ii 0;  // Show data mode

Set Labels

For each matrix object, you can set Long Name, Comments, and Units, by using Range Notation, which is a matrix object.

// Create a new matrixbook
newbook mat:=1;

// Set number of matrix object of 1st matrixsheet to be 3
wks.nMats = 3;

// Show image thumbnails
matrix -it 1;

// Activate 1st matrix object
wks.active = 1;

// Set Long Name, Units, and Comments
range rx = 1;  // 1st matrix object of the active matrixsheet
rx.lname$ = X;  // Long Name = X
rx.unit$ = cm;  // Unit = cm
rx.comment$ = "X Direction";  // Comment = "X Direction"

// Do the same thing for matrix object 2 and 3
wks.active = 2;
range ry = 2;
ry.label$ = Y;  // Long Name can also be set in this way
ry.unit$ = cm;
ry.comment$ = "Y Direction";
wks.active = 3;
range rz = 3;
rz.label$ = Z;
rz.unit$ = Pa;
rz.comment$ = Pressure;

Delete Matrix Object

To delete a matrix object, you can use the delete command.

// Delete a matrix object by range
range rs=[mbook1]msheet1!1;  // The first matrix object
del rs;
// or delete a matrix object by name
range rs=[mbook1]msheet1!Channel2;  // The object named Channel2
del rs;