10 Matrix Book Matrix Sheet Matrix Objects

Less grand image matrices 650px.png

Matrixbooks, Matrixsheets 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. The following table summarizes some important matrixbook limits:

Maximum Number of... 32Bit OS 64Bit OS

Matrixsheets in a matrixbook
Matrix objects in a matrixsheet
Cells in a matrix (Note)



† > 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 Matrixbooks, Matrixsheets and Matrix Objects

Matrix Book Mult Object 2.png

  • The matrixbook 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.
  • The sheet Name must be unique within the matrixbook and is limited to 32 characters.
  • Can contain spaces and numbers.
  • Can contain special characters except `!%"|()[]{}<>.
  • Can begin with a letter, number or allowed special character.
  • Optionally, sheet can have Label and Comments.
Matrix Objects
  • By default, Origin assigns a matrix object index number to each object, as it is created. This index number cannot be changed.
  • You can add a name to the object by clicking on the yellow object icon - Matrix object icon data.png for a data matrix or Matrix object icon image.png for an image matrix - in the upper right corner of the matrixsheet and choosing Rename from the menu. Alternately, you can double-click on the matrix object number/name below the thumbnail and enter a name.

You can now rename a matrix or virtual matrix in the Object Manager. Right-click on name in Object Manager and choose Rename.

Different Views of the 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 linearly-spaced X values.
  • Matrix rows are mapped to linearly-spaced 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 gray-scale image while RGB values will display as a color image.

Datamode imagemode.png

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:

  1. 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.
  2. Click the Rectangle Tool ROI rectangle tool.png button on the Tools toolbar.
  3. Drag out a rectangular area on the image.
  4. Right-click on the rectangle and select Crop from the shortcut menu.

Matrix image crop.png

Note: If the matrix object is an image, the object icon will display as Matrix object icon image.png 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 Matrix object icon data.png regardless of view mode.


Like the workbook window, the matrixbook 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 matrixsheets, matrix dimensions, data type, math functions, data import handling instructions as well as various style and format options.

When you create a new matrixbook, 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 matrixsheet. 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).

Matrix window gsb.png

You can right-click on a worksheet tab and Add Matrix as Sheet and insert a matrixbook into a workbook. This is useful when building Analysis Templates that involve matrix-based operations such as 3D surface fitting or 3D plotting operations.

Workbook add matrix.png


Prior to Origin 2018, an Origin matrixbook 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 Unicode-compliant formats (opju, ogmu, etc).

A matrixbook can have up to 1024 matrixsheets. The default matrixbook template - ORIGIN.otmu - has a single matrixsheet containing 32 rows and 32 columns. Each matrixsheet can differ in dimensions(number of rows and columns and X & Y range).

To specify the dimensions of the matrixsheet:

  1. Click on a tab to activate the sheet and choose Matrix:Set Dimensions/Labels. This opens the Matrix Dimensions and Labels dialog box.
  2. Specify a number of columns (X dimension) and rows (Y dimension).
  3. 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 matrixsheet can contain up to 65,504 matrix objects, 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:

  1. Make sure that the matrix object is active (check mark shows beside it in the object menu).
  2. 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.

Apply properties other matrices.png

Apply settings of the active matrix object to all matrix objects to the right by checking the Apply to matrices to the right box.

Show Image Thumbnails

You can show image thumbnails for each object in the sheet:

  1. Right-click on the matrix window title bar and place a check mark beside Show Image Thumbnails.
UG Show Image Thumbnails.png

As an alternative to image thumbnails, you can use a slider to display images in the matrixsheet. If you are seeing thumbnail images at the top of the sheet, you can replace them with a slider by doing the following:

UG MT Matrix Slider Thumbnail.png
  1. Hover in the gray area just to the right of your matrix image and just below the image thumnails. When the cursor shows the Mini Toolbar prompt, click to show the toolbar, then click the Slider or Thumbnails button.
  2. To revert to display of image thumbnails, click the button again.
UG Matrix Slider Enabled.png

Note that you can disable display of both thumbnails and slider by clicking the Image Selector button located just to the left of the Slider or Thumbnails button on the Mini Toolbar.

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).

Viirtual matrix GSB remade.png

Note: You can create 3D plots from XYZ columns of worksheet data in which data are irregularly spaced in the X and Y dimensions. This is not considered a "virtual 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 matrixbook, 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:

  1. With the matrix window active, choose File: Save Template As from the main menu. This opens the template_saveas X-Function dialog box.
  2. Select a category from the Category drop-down list or enter a new category.
  3. Select or type a file name in the Template Name box (the .otmu extension is automatically added).
  4. Enter a description into the Template Description text box (optional).
  5. 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.

Dialog Box What is Saved? Menu Access
  • The Organizer
  • The Script Panel
  • The Matrix Image Thumbnails
Right-click 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

Utility Menu Access
  • Flip or Rotate
Matrix: Rotate90
Matrix: Flip: Vertical
Matrix: Flip: Horizontal
  • Expand (by interpolation)
Matrix: Expand
  • Shrink
Matrix: Shrink
  • Transpose
Matrix: Transpose
  • Convert to Worksheet
Matrix: Convert to Worksheet

Setting 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:

  1. From the menu, choose Matrix: Set Values.


  1. Select the matrix by clicking in the upper-left corner (in the empty header cell just below the matrix icon/name), then right-click on the matrix and choose Set Matrix Values from the shortcut menu.

SetValues matrix.png

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 Search Insert Functions.png to search for built-in LabTalk functions.

Extracting Matrix Data

You are allowed to extract a block of matrix data you are interested from an image-viewing matrix object, using the ROI tool ROI for Matrix Image.png.

To extract a block of matrix data from a matrix obejct:

  1. Activate the matrix window and select the target matrix object.
  2. Select View: Image Mode to show the matrix image. Click on the Rectangle tool button ROI for Matrix Image.png at the Tools toolbar docked at the left side of Origin workspace.
  3. Draw a rectangle box on the matrix image to select the block of matrix data you want to extract. Right-click on the rectangle box you just drawn, select Create New from the context menu to extract the selected block to a new matrix window.
    Extract Matrix Data 01.png

    You can also select Copy context menu to copy the selected area and paste it into another matrix worksheet/workbook.

For Origin 2021, Origin supports various shapes for ROI box when extracting data from a matrix while viewing in image mode (View: Image Mode).
ROI for Matrix Image 2021.png

Converting Worksheets to Matrixes

There are four methods for converting worksheet data to matrix data.

Method Conversion Type Notes
  • 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.
  • Row
  • Column
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 Renka-Cline, 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

There are two methods for converting matrix data to worksheet data:

Matrix Source.png
  • 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.
    Matrix direct convert.png
  • 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.
    Matrix wks XYZ.png

Profiling Matrix Data

Data in a matrix can be viewed in profile -- either in the X, Y or arbitrary cross-section.

  1. 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 cross-sectional lines. Note that this dialog box is interactive. You can make adjustments to your image profile -- move the cross-sectional 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 right-top corner of graph window, which can be used to reopen the Image/Contour Profiles dialog.

Image profile XY.png

Topics for Further Reading