Matrix: Convert to Worksheet
Convert the Matrix data into a Worksheet
Minimum Origin Version Required: Origin 8 SR0, updated in Origin 8.5.1
1. m2w;
2. m2w im:=[MBook1]MSheet1!Mat(1) ow:=[Book1]Sheet1!;
3. m2w method:=direct xy:=xcol ycol:=1 xlabel:=row1;
4. m2w method:=xyz option:=yconst;
5. m2w method:=xyz trim:=1;
6. m2w -r 1 ims:=[MBook1]MSheet2! method:=xyz multi:=all;
Please refer to the page for additional option switches when accessing the x-function from script
Display Name |
Variable Name |
I/O and Type |
Default Value |
Description |
---|---|---|---|---|
Input Matrix | im |
Input MatrixObject |
|
Specifies the source matrix object. |
Input Matrix | ims |
Input MatrixLayer |
|
Specifies the source matrix sheet. If you want to convert all objects in a Matrix sheet, you need to use the ims to specify the source instead of im.
|
Method | method |
Input int |
|
Specifies the conversion method.
|
Data Format | xy |
Input int |
|
This variable is available only when Direct is selected for Method. It specifies how to arrange the data in the target worksheet.
|
Y Values in First Column | ycol |
Input int |
|
This is available only when X across columns is selected for Data Format. It specifies whether to output the matrix Y values to the first column of the target worksheet. |
X Values in First Column | xcol |
Input int |
|
This is available only when Y across columns is selected for Data Format. It specifies whether to output the matrix X values to the first column of the target worksheet. |
X Values in | xlabel |
Input int |
|
This is available only when X across columns is selected for Data Format. It specifies whether to output the matrix X values and, if you want to output them, the place to save them.
|
Y Values in | ylabel |
Input int |
|
This is available only when Y across columns is selected for Data Format. It specifies whether to output the matrix Y values and, if you want to output them, the place to save them.
|
System Parameters | sysparam |
Input int |
|
This is available only when System Parameters is selected for X Values in or Y Values in. It specifies the system parameter column label row that will be used to save the matrix X/Y values.
|
User Defined Parameter | userdef |
Input string |
|
This is available only when System Parameters is selected for X Values in or Y Values in. It specifies a user parameter row to save the matrix X/Y values. |
Convert on | multi |
Input int |
|
When there are multiple Matrix objects in a Matrix sheet, you can specify to convert one object only, or all objects.
Option List:
Note: For these two options, the input variable is different. |
Option | option |
Input int |
|
This variable is available only when XYZ Columns is selected for Method. It specifies how to sort the worksheet values.
|
Trim Missing Values | trim |
Input int |
|
This check-box is only available when Method is XYZ Columns. If checked, the missing values in the matrix will be skipped and not included in the result worksheet. If not, the missing values will also show in the result worksheet. |
Output Worksheet | ow |
Output Worksheet |
|
Specifies the output worksheet. See the syntax here. |
The matrix displays a single data set of Z values. It is characterized by:
By default, Origin displays the column and row numbers in the column and row headings (left figure). To display X and Y values (right figure) select View: Show X/Y from menu.
To convert a matrix into worksheet, there are two methods: direct conversion and creating a worksheet with XYZ columns.
Direct conversion:
1. No X and Y
Only the matrix cell values are converted.
2. X across columns
Matrix values are arranged in worksheet columns according to their X mapping values: Matrix values corresponding the same X value will be arranged in the same column, while any two matrix values that correspond to different X values will be arranged in different columns.
In this method, you can specify whether or not to output the matrix X/Y values to the first worksheet row/column, or to a worksheet label. The following example uses direct conversion and puts the X values in the first row and Y values in the first column of the target worksheet:
3. Y across columns:
Matrix values are arranged in worksheet columns according to their Y mapping values: Matrix values corresponding the same Y value will be arranged in the same column, while any two matrix values that correspond to different Y values will be arranged in different columns.
In this method, you can specify whether or not to output the matrix X/Y values to the first worksheet row/column, or to a worksheet label. The following example uses direct conversion and puts the Y values in the Parameters 1 row and X values in the first column of the target worksheet:
Creating a worksheet with XYZ columns:
This method creates a worksheet with X, Y, and Z columns. The cell values of the matrix are converted to Z data in the worksheet. The corresponding X and Y column values in the worksheet are set with the X and Y mapping values in the matrix. And you can specify how to sort the converted worksheet with the Option variable.
1. X Const 1st: Sorts values in the target worksheet by their X mapping values in the source matrix in ascending order first and then by their Y mapping values in ascending order.
2. Y Const 1st: Sorts values in the target worksheet by their Y mapping values in the source matrix in ascending order first and then by their X mapping values in ascending order.
/* This example shows how convert matrix data into XYZ worksheet columns. The sample data is exe_path\Samples\Matrix Conversion and Gridding\Direct.dat. 1. Load data to a new created matrix. 2. Convert matrix to XYZ worksheet data. */ // Get sample file name fn$ = system.path.program$ + "Samples\Matrix Conversion and Gridding\Direct.dat"; // Create a matrix window win -t matrix origin; // Import data to active matrix impASC fn$; // Convert active matrix to XYZ workshseet data, by X Const 1st option m2w m:=1;