
Contents |
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;
| Display Name | Variable Name | I/O and Type | Default Value | Description |
|---|---|---|---|---|
| Input Matrix | im |
Input MatrixObject | |
Specifies the source matrix. |
| 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. |
| 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 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.
To convert the active matrix into a worksheet with direct conversion:
1. Create a new matrix and import the file \Samples\Matrix Conversion and Gridding\Direct.dat.
2. Select Matrix: Convert to Worksheet from the Origin menu to bring up the dialog.
3. Choose Direct from the Method drop-down list and No X and Y from the Data Format drop-down list. Click the OK button to execute.
To create a worksheet with XYZ Columns and sort by X mapping value:
1. Create a new matrix and import the file \Samples\Matrix Conversion and Gridding\Direct.dat.
2. Select Matrix: Convert to Worksheetfrom the Origin menu to bring up the dialog.
3. Choose XYZ Columns from the Method drop-down and X Const 1st from the Option the drop-down. Click the OK button to execute.
For more examples, please refer to XF Script Dialog (press F11).