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.
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
 For Origin 2022, you can assign a name to a matrix object:  With the matrix object active, choose Data: Define Name.
 Give the matrix a Name, set Scope and, optionally, add a Comment.
Named ranges can be used in Matrix: Set Values (e.g. to perform math operations on other matrix objects of the same dimensions). 
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 box 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.
 Origin 2022 adds a Copy to shortcut command for copying the selected matrix object to a new sheet or book.

Extracting Information from the Matrixsheet or Object
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.
 In Origin 2022, ROI stats are automatically reported to the Status Bar. Rightclick on the Status Bar to hide or show statistics.

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.
Image Window
 The Image Plot described above is used to plot values in a single matrix object. The Image Window can be used to:  Open an image file for basic manipulation (flip, rotate, convert to grayscale) using the Image Window's Mini Toolbar.
 Edit an image inserted into a worksheet cell or graph window (doubleclick on the inserted image).
 Import an image set such as the common "TIFF stack".
 Import multiple discrete image files as an image stack.
 Open and play a movie (.avi, .mov, .mp4) file.
 Define one or more regionsofinterest (ROI) for which you can Copy Positions, Paste Positions (from another ROI), and Export or Import position information saved to an Origin *.ROI file (a text file with position information on each ROI on the image).
 Open and operate on images inserted to worksheets or graphs: crop, copy, export ROI, etc.

 The degree of image darkening outside of the Image Window ROI is controlled by system variable @IMGDI. Setting @IMGDI = 1000 will cause the outside area to display as black; @IMGDI = 0 turns off darkening. For information on changing the value of a system variable, see this FAQ.

Image and Video Import
 Choose File: New Image, then choose an option from the flyout menu.
 If you choose Image/Video, use the file type dropdown to specify an image or video file format.
 If you choose Multiple Image Files, you'll specify which files to import as a stack. Note that the resulting stack will show an image slider, by default.
 If you choose Empty Window, you can subsequently add a file by rightclicking and choosing Import.
Image Import Notes
 To help control Origin project file size, rightclick on an Image Window image and enable Linked File. This saves a link to the image file into the window but excludes the image from the saved project. When you reopen the saved project, the window will appear empty; at this point, you can decide whether you need to reimport the image (CTRL + 4 or Import from the window shortcut menu).
 Actual Size Mode is turned on by default for images of max width or height of less than 800 pixels. The size threshold can be adjusted using system variable @IWP (see this FAQ for info on changing the value of a system variable).
Image Window Navigation
Display of image information and navigation controls is enabled or disabled via the the View menu and/or the Image Window Mini Toolbar (None, Thumbnails, Video or Slider).
Keyboard access to video navigation
 Pressing the left/right arrow keys will move the frame by 1.
 Shift + arrow key will move the frame by 5.
 Shift + Ctrl + arrow key will move the frame by 20.
Image Resize
To resize the image by one of several interpolative methods:
 With the Image Window active, choose Image: Resize.
 Choose options including your Interpolation Method (Nearest Neighbor, Bilinear, Bicubic, Pixel Area Relation, Lanczos) and click OK.
Define ROIs
You can define a regionofinterest using the Rectangle Tool on the Tools toolbar.
 Select the tool and drag out a rectangle. Once added, fine adjustments can be made by dragging the blue handles.
 To add multiple ROIs to an image, you will need to rename each ROI as it is created. Doubleclick on the ROI to open the ROI Position dialog box and assign a new Name. You can also adjust size/position (From/To) of an ROI using this dialog.
 When the ROI is selected, use the Style toolbar Line/Border Color button to change the outline color of the ROI.

Mini Toolbars for Image Window
Mini Toolbar buttons are available for performing simple image manipulation, including rotating, flipping or converting to grayscale.
 You can apply a color palette to a grayscale image using the Palette button on the Style toolbar. Click More Palettes to open the Color Manager dialog box and add more palettes.

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.
 For Origin 2022, you can assign a name to a matrix object and use the name Set Values (e.g. to perform math operations on other matrix objects of the same dimensions). In addition, there is now Auto Complete support for functions and named ranges when typing in the formula box. 
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
 Origin 2022 improves missing values handling for Matrix: Shrink and Matrix: Expand. 
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


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

Changing the Color Scheme of a Matrix
You can use the Palette button and the Missing Value Color button in the Mini Toolbar to customize the color of the matrix window.
 The selected palettes and missing value color will apply to all matrix objects in the active matrix sheet, but will not change the palettes and missing value colors of objects in other matrix sheets in the same matrix window.

Converting Matrixes to Worksheets
Worksheets, Converting from Matrix
Matrix, Converting to Worksheet
 For Origin 2022, there are new output options for Method: XYZ Columns:  Save matrix object Long Name, Units and Comments to the Z column label rows.
 Convert on = All Objects will output multiple matrix objects to a worksheet with column designations of XYZZZ..., one Z column for each matrix object.
In addition, if the converted matrix contains a color image, the resulting Z column will display a Color column of HTML colors for each matrix cell.

To convert a matrix to worksheet:
 With a matrix active, choose Matrix: Convert to Worksheet: Open Dialog.
There are two methods for converting matrix data to worksheet data  Direct and XYZ Columns. Starting, for instance, with the following arrangement:
 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: When there is a single matrix object, this method produces a worksheet with three columns: X,Y, and Z, with X and Y columns containing the X and Y coordinate values and the Z column containing the matrix Z value at each XY coordinate.
When there are N matrix objects, you can set Convert On = All Objects and output columns as X, Y and Z x N (i.e. XYZZZ...).
Converting Worksheets to Matrixes
 With the worksheet active, choose Worksheet: Convert to Matrix and choose one of the following methods:
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. Option for No Extrapolation outside Boundary.

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
