10 Matrix Book Matrix Sheet Matrix ObjectsMatrixBookMatrixSheetMatrixObjects
Matrix Books, Matrix Sheets and Matrix Objects
A matrix is a dataset of Z values arranged as an array of columns and rows which are linearly mapped to X and Y values.
Limitations, Matrix
The following table summarizes some important matrix book limits:
Maximum Number of...

32Bit OS

64Bit OS

Matrix sheets in a matrix book
Matrix objects in a matrix sheet
Cells in a matrix (Note)

1024†
65,527
90,000,000

1024†
65,527
90,000,000

† > 255 sheets requires saving file to Unicode (e.g. *.opju) file format. Unicode formats not compatible with Origin versions prior to Origin 2018 SR0.
Note: The product of any combination of rows and columns must not be greater than 90,000,000.

Naming Matrix Books, Matrix Sheets and Matrix Objects
Naming Matrix Books
Matrix Books, Naming
Matrix Sheets, Naming
Naming Matrix Sheets
Matrix Objects, Naming
Naming Matrix Objects
Matrix Book

 The matrix book has a Short Name whether you display it or not. Origin uses the Short Name for internal operations.
 Short Names must be unique within the project file, cannot contain spaces, must begin with a letter, consist only of alphanumeric characters (A to Z and 0 to 9), and limited to 13 characters. You can use lowercase characters and the text will appear as such, but upper and lower case are not unique characters. (You cannot name one matrix MBOOK1 and another mbook1.)
 Long Names are optional, need not be unique within the project file, can contain spaces, can begin with a letter, a number or a special character, and the length cannot exceed 520 characters, including spaces.

Matrix Sheets

 The sheet Short Name (a Layer object) must be unique within the matrix book and is limited to 32 characters.
 Can contain spaces, numbers and special characters.
 Can begin with a letter, number or special character.
 These special characters are not allowed: `!%"()[]{}<>.

Matrix Objects

 Origin assigns a Short Name  the matrix object index number  to each matrix object, as it is created. This name/index number cannot be changed.
 You can add an optional Long Name to the object by clicking on the yellow object icon  for a data matrix or for an image matrix  in the upper right corner of the matrix sheet and choosing Rename from the menu.

Different Views of the Matrix
Matrix, Data Mode vs. Image Mode
Region of Interest
Images, Matrix
In the worksheet, a dataset is contained in a single column and the dataset may consist of X,Y,Z, Error, or Label data. In the Origin matrix, a dataset is arranged in a specified dimension of rows and columns. The matrix contains a single dataset of Z values.
 Matrix columns are mapped to linearlyspaced X values.
 Matrix rows are mapped to linearlyspaced Y values.
Note that the matrix window has two column and row heading view modes:
 By default, matrix row and column headings display as row and column index numbers (View: Show Column/Row from the menu or press Ctrl+Shift+C).
 You can opt to view matrix row and column as X and Y values by choosing View: Show X/Y from the Origin menu (or press Ctrl+Shift+X). The displayed X and Y values are the X and Y coordinate values, calculated by linear interpolation of the axes From and To values by the number of columns and rows.
In addition to the two row and column heading view modes, there are two matrix display modes:
 In Data Mode (View:Data Mode from the menu or press Ctrl+Shift+D), the matrix object displays as raw numbers.
 In Image Mode (View:Image Mode from the menu or press Ctrl+Shift+I), the matrix object displays as either a gray scale image or a color image, depending upon the type of data in the matrix. A matrix of real numbers or complex numbers displays as a grayscale image while RGB values will display as a color image.
An image in a matrix can be cropped within the existing window or it can be cropped and copied to create a new matrix window:
 Make sure that there is a check mark beside Region of Interest Tools on the Tools menu. If this menu item is not checked, select it.
 Click the Rectangle Tool button on the Tools toolbar.
 Drag out a rectangular area on the image.
 Rightclick on the rectangle and select Crop from the shortcut menu.
Note: If the matrix object is an image, the object icon will display as whether you are viewing the matrix object as an image (View:Image Mode) or as numbers (View:Data Mode). Likewise, when the matrix object contains numbers, the object icon will display as regardless of view mode.

Matrix Books
Matrix Objects
Like the workbook window, the matrix book window is created from a customizable template (.otmu file). The matrix template stores such things as number of sheets in the book, the names of the matrix sheets, matrix dimensions, data type, math functions, data import handling instructions as well as various style and format options.
When you create a new matrix book, the book is named MBookN, with N reflecting the order of window creation. Appended to the book name, you will see something like ":1/3" where the first integer denotes the active matrix object and the second denotes the number of matrix objects in the active matrix sheet. Following the above example, if you click the yellow object icon to the right side of the matrix, the menu shows three matrix objects with the first being the active one  the one with a check mark placed beside it (note that in our illustration, the objects are empty).
 You can rightclick on a worksheet tab and Add Matrix as Sheet and insert a matrix book into a workbook. This is useful when building Analysis Templates that involve matrixbased operations such as 3D surface fitting or 3D plotting operations.

Matrix Sheets
 Prior to Origin 2018, an Origin matrix book could a maximum of 255 sheets. That number is now increased to 1024. When you have more than 255 sheets in a book, you will need to save the file using one of the new Unicodecompliant formats (opju, ogmu, etc).

A matrix book can have up to 1024 matrix sheets. The default matrix book template  ORIGIN.otmu  has a single matrix sheet containing 32 rows and 32 columns. Each matrix sheet can differ in dimensions(number of rows and columns and X & Y range).
To specify the dimensions of the matrix sheet:
 Click on a tab to activate the sheet and choose Matrix:Set Dimensions/Labels. This opens the Matrix Dimensions and Labels dialog box.
 Specify a number of columns (X dimension) and rows (Y dimension).
 Specify a From and To value for X (columns) and Y (rows).
Note: The X and Y coordinates of the matrix are evenly spaced. The first X is mapped to the first matrix column and the last X is mapped to the last matrix column. The X coordinates of other columns are interpolated. Matrix rows are similarly mapped using the From Y and To Y values. When plotting or analyzing matrix data, the position of a point in 3D space is determined by the column X and row Y coordinate values (not column or row index) and the Z value contained in the cell intersected by the row and column.

Matrix Objects
A matrix sheet can contain up to 65,504 matrix objects (64bit, 32bit max = 43,339), though the actual limit is likely to be far less (determined by system resources). Objects in a sheet share the same X/Y dimensions and column (X) and row (Y) headers, but every object can have its own Z header. Other matrix object properties include internal data type and numeric display options.
Matrix object properties are set in the user interface via the Matrix Properties dialog box. To open the dialog box:
 Make sure that the matrix object is active (check mark shows beside it in the object menu).
 Choose Matrix:Set Properties... from the main menu.
 You can set properties for multiple matrix objects without closing the Matrix Properties dialog boxes by clicking the Previous or Next buttons at the top of the dialog box.

Virtual Matrix
Matrix, Virtual
Virtual Matrix
Data arranged in a block of worksheet cells can be treated as a "virtual matrix". As is the case with regular matrix data, virtual matrix data can be used to create 3D plots, such as color mapped surfaces or contour plots. The data can include a column or label row with the X or Y values. Unlike a regular matrix which only supports a linear spacing in the X and Y dimensions, a virtual matrix supports irregular spacing of X and Y coordinate values (provided those values are in ascending or descending order).
Matrix Templates
Templates, Matrix
Matrix Templates
Matrix windows are created from a matrix template file (*.otmu). The template file saves such things as the number of sheets in the matrix book, the number of rows and columns in each sheet, internal memory allocated for each sheet, mathematical formula used to fill the matrix with numbers and certain ASCII import and export options.
Note: Data are NOT saved with the matrix template file.

To save the active matrix window as a template:
 With the matrix window active, choose File: Save Template As from the main menu. This opens the template_saveas XFunction dialog box.
 Select a category from the Category dropdown list or enter a new category.
 Select or type a file name in the Template Name box (the .otmu extension is automatically added).
 Enter a description into the Template Description text box (optional).
 Type the file path for the template or click the browse button to locate your folder. Typically, you would save your template to your User Files folder.
The following table lists some of the kinds of things that are saved with the matrix template file. It also tells you where to find these controls.
Matrix Organizer
Matrix, Script Panel
Dialog Box

What is Saved?

Menu Access



 The Organizer
 The Script Panel
 The Matrix Image Thumbnails

Rightclick on window title bar and choose:
 Show Organizer
 Show Script Panel
 Show Image Thumbnails

Matrix Properties

 Matrix Long Name, Units, Comments.
 Column width settings.
 Column number Display (decimal, scientific, engineering).
 Column Digits and data storage requirements.

Matrix:Set Properties

Matrix Dimensions and Labels

 Numbers of rows and columns in the matrix, xy coordinates, XYZ axis labels.

Matrix:Set Dimensions/Labels...

Set Values

 Formula used to create or transform matrix values.

Matrix: Set Values ...

ASCII Import Options

 ASCII import options pertinent to the matrix window are saved with the template.

Data: Import From File: Single ASCII Data: Import From File: Multiple ASCII

Simple Manipulation of Matrix Data
Matrix, Manipulating Data
Utility

Menu Access


Matrix: Rotate90 Matrix: Flip: Vertical Matrix: Flip: Horizontal

 Expand (by interpolation)

Matrix: Expand


Matrix: Shrink


Matrix: Transpose


Matrix: Convert to Worksheet

Setting Matrix Values
Matrix, Set Values
Set Matrix Values
The Set Values dialog box is used to generate or transform data in a matrix object.
To open the Set Values dialog box, make sure that the matrix object is active, then:
 From the menu, choose Matrix: Set Values.
or
 Select the matrix by clicking in the upperleft corner (in the empty header cell just below the matrix icon/name), then rightclick on the matrix and choose Set Matrix Values from the shortcut menu.
Menu Commands

 Formula: Load a saved formula into the matrix formula box. Formula are saved using Formula: Save or Formula: Save As....
 Mat(1): Use the menu to include matrix objects in either your matrix formula or your Before Formula Scripts (matrix object reference is inserted at the cursor). A Matrix Browser is available to help in selecting the correct objects. Objects are listed by object index.
 Mat(A): Similar to Mat(1) menu functionality but matrix objects are listed by object Long Name, if one exists.
 Function: Add LabTalk functions to your expressions (function name is inserted at the cursor).
 Variables: Add a variable or a constant to Matrix Formula or Before Formula Scripts; Add range variables (including by selection) or file metadata, to Before Formula Scripts.

Matrix Formula

 Add a single line expression for generating data. Functions, conditional operators and variables can be used.

Before Formula Scripts

 Enter one or more lines of LabTalk script to be executed before the expression in the Matrix formula box is executed.

 Use the Before Formula Scripts panel at the bottom of the Set Values dialog box to define variables or LabTalk functions that you wish to use in your matrix formula.
Click the Search and Insert Functions button to search for builtin LabTalk functions.

Converting Worksheets to Matrixes
There are four methods for converting worksheet data to matrix data.
Worksheets, Converting to Matrix
Matrix, Converting Worksheet Data
Method

Conversion Type

Notes

Direct

 X across columns
 Y across columns
 No X and Y

Ideal for spreadsheet data that conforms to the following:
 X data values in the 1st column, Y data values in the 1st row and Z values in columns 2 to N and rows 2 to M.
 Y data values in the 1st column, X data values in the 1st row and Z values in columns 2 to N and rows 2 to M.

Expand


Some ASCII files have an upper limit for characters allowed on a single line. Use this method when your file breaks a single line of data across multiple lines.
 Expand by Row: specifies the number of ASCII file rows comprising one matrix row.
 Expand by Column: specifies the number of ASCII file columns comprising one matrix column.

XYZ Gridding

 Regular
 Sparse
 Random (Renka Cline)
 Random (Shepard)
 Random (Thin Plate Spline)
 Random (Kriging Correlation)
 Random (Weighted Average)

Conversion Type depends upon XY spacing:
 Choose Regular applied for data that are regularly spaced in XY.
 Choose Sparse when you have missing values.
 Choose RenkaCline, Shepard, TPS, Kriging or Weighted Average methods for data that are irregularly spaced in XY.

XYZ Log Gridding

Methods same as XYZ Gridding

Calculates logarithmic values for X and Y, then performs XYZ Gridding.

Converting Matrixes to Worksheets
Worksheets, Converting from Matrix
Matrix, Converting to Worksheet
There are two methods for converting matrix data to worksheet data:
 Direct: This copies the Z values in the matrix to a worksheet with no reordering. If the matrix consists of M rows by N columns of Z values, this method produces a worksheet which has M rows and N columns. By default, the X and Y coordinates of the matrix Z values are not copied to the worksheet. You can opt to copy X coordinates to the 1st worksheet row or a parameter row and the Y coordinates to the 1st worksheet column.
 XYZ Columns: This method produces a worksheet with three columns: an X, a Y and a Z column. The X and Y columns contain the X and Y coordinate values of the matrix Z values. The matrix Z values are contained in the worksheet Z column.
Profiling Matrix Data
Profiling Matrix Data
Matrix, Profiling
Profiling Images
Data in a matrix can be viewed in profile  either in the X, Y or arbitrary crosssection.
 Activate the matrix object and choose Plot > 2D: Profile: Image Profiles from the main menu.
This creates an image plot and opens the Image/Contour Profile dialog box. Use the dialog box to specify X and/or Y profile plots and the location and appearance of the crosssectional lines. Note that this dialog box is interactive. You can make adjustments to your image profile  move the crosssectional lines or change the configuration or the appearance of the plots  without closing the dialog box. After closed the dialog box, a button Profiles...will appear at the righttop corner of graph window, which can be used to reopen the Image/Contour Profiles dialog.
Topics for Further Reading
