10 Matrix Book Matrix Sheet Matrix ObjectsMatrixBookMatrixSheetMatrixObjects
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.
Limitations, Matrix
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)

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

 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.

Matrixsheets

 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  for a data matrix or for an image matrix  in the upper right corner of the matrixsheet and choosing Rename from the menu. Alternately, you can doubleclick on the matrix object number/name below the thumbnail and enter a name.

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.
Note: If the matrix object is an image, the object icon will display as whether you are viewing the matrix object in Image Mode (View: Image Mode) or Data Mode (View: Data Mode). Similarly, when you import numeric data into the matrix, the object icon will display as regardless of View mode.

Matrixbooks
Matrix Objects
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.
 The New Book dialog in Origin 2021b is an updated template library for managing workbook, matrixbook and Analysis Templates. See Workbooks for an overview of dialog box features. 
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).
 You can rightclick 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 matrixbased operations such as 3D surface fitting or 3D plotting operations.

Matrixsheets
 Prior to Origin 2018, an Origin matrixbook could have 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 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:
 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 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:
 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.

Image Thumbnails and Image Slider
When the sheet contains multiple objects, you can display those objects as a series of thumbnails in a spacer at the top of the matrix window.
 Rightclick on the matrix window title bar and place a check mark beside Show Image Thumbnails.
Alternately, you can use a slider control to view these objects in the active matrixsheet.
If you are seeing thumbnail images in the spacer at the top of the window, you can switch to the slider by doing the following:
 Hover in the space between the thumbnails and when the cursor changes to a grid icon , click to show the page Mini Toolbar (you can also click in the gray area to the right of your matrix image).
 Toggle the Slider or Thumbnails button to show slider or thumbnails.
 Likewise, you can turn off both thumbnails and slider by clicking the Image Selector button. Click the View Image button to toggle between Data Mode and Image Mode.
Extracting Information from the Matrixsheet or Object
 Tools for extracting information from a matrix regionofinterest have been greatly improved for Origin 2021b. 
When viewing matrixsheets or matrix objects in Image Mode (View: Image Mode), you can extract information from the matrix using the RegionofInterest (ROI) tools:
 Go to Tools: Region of Interest Tools and verify that there is a check mark beside the menu item. If not, click on this item or press CTRL + SHIFT + T to enable the ROI tools.
 Click on the displayed ROI tool (e.g. Rectangle Tool ) on the Tools toolbar and choose an ROI shape from the flyout menu (rectangle, circle, polygon, region).
 Using your mouse, drag out an area on the image and doubleclick to set your selection. Once the selection is set, additional clicks allow rotating, stretching, or skewing the ROI.
 To add multiple ROI to a matrix, you must give each ROI a name that is unique within the matrixsheet. Doubleclick on the ROI to open a small dialog with access to the object name.
 Rightclick on your ROI and choose an option from the shortcut menu. To discard the ROI, press Delete:
 Crop: Crop the image to the minimum rectangular area that will contain the ROI. By default, values outside the ROI will show black (zero values in Data Mode).
 Copy: Rectangle only. Creates an image from the ROI.
 Copy Positions: Copy the position of the selected ROI.
 Paste Positions: Paste the position of the selected ROI to another ROI (width, height...all).
 Export ROI: Save the ROI object(s).
 Import ROI: Replace the object(s) with those in a saved .ROI file (hint: create a "dummy" ROI to import).
 Create New: Use the mroi2mat tool to generate a new matrix from the ROI.
 Extract as XYZ: Use the mroi2xyz tool to generate a new worksheet of XYZ values.
 Intensity Profile: Use the mroiprofile tool to generate a statistics for the ROI.
Image Plot
Data in a matrix can be plotted as an Image Plot. Axis scales are determined by the matrix XY coordinates (when the matrix is active, choose View: Show X/Y).
 Activate a matrix window and choose Plot: Contour: Image Plot.
By default, the image plot will use the same colormap, Z scale range and missing value color, as matrix image mode (View: Image Mode). See Matrix: Apply Palette to Color Map, below.
 The matrix Mini Toolbar now has a button for setting the Missing Value Color.

Image Window
 The Image Plot described above is used to plot values in a single matrix object. The Image Window can be used to:  Plot an image set such as the common "TIFF stack", as a series of bitmapped images.
 Open and play a movie (.avi, .mov, .mp4) file.

To open an Image Window:
 Choose File: New Image.
 Use the file type dropdown to specify an image format or video file.
 Select a file and click Open.
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.
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.

Manipulation of Matrix Data
Matrix, Manipulating Data
Utility

Menu Access

 For an XY coordinate pair picked with the Screen Reader, output Z values for for the matrix stack (multiple matrix objects) to a worksheet. 

Matrix: Pixel Extraction


Analysis: Linear Fit on Matrix Stack

 Output descriptive statistics (mean, sd, min, max, etc.) on the matrix stack (series of matrix objects), for each pair of XY coordinates. 

Analysis: Descriptive Statistics

 Subtract two matrices of the same size, at each XY coordinate pair. 

Analysis: Mathematics: Subtract


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

 Resize a matrix using one of four methods (Expand, Shrink, Interpolate and Pad). 

Matrix: Resize


Matrix: Transpose

 Generate a 3dimensional dataset by transforming XYZ values by formula. 

Matrix: Generate Grid

 Expand the matrix by scaling in the X and Y directions.

Matrix: Expand

 Shrink the matrix by some row/column factor, using one of several shrink methods.

Matrix: Shrink

 Use a palette file to transform a matrix in Image Mode.
 Set a system variable to apply a color palette (Style toolbar, Palettes button) to all matrix objects (@MAP=0, default) or only the active matrix object (@MAP=1). 

Matrix: Apply Palette to Color Map

 Convert a matrix of values to worksheet columns (see next section).

Matrix: Convert to Worksheet

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.
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.
Note: See Virtual Matrix, below.

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.
 A new No Extrapolation outside Boundary check box is added so that gridding does not extrapolate beyond the boundaries defined by XYZ data. Applies only to Random methods (not Sparse or Regular). 

XYZ Log Gridding

Methods same as XYZ Gridding

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

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).
Topics for Further Reading
