2.2.1.1 m2w
Menu Information
Matrix: Convert to Worksheet
Brief Information
Convert the Matrix data into a Worksheet
Additional Information
Minimum Origin Version Required: Origin 8 SR0, updated in Origin 8.5.1
Command Line Usage
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;
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
Variables
Display Name
|
Variable Name
|
I/O and Type
|
Default Value
|
Description
|
Input Matrix
|
im
|
Input
MatrixObject
|
<active>
|
Specifies the source matrix object.
|
Input Matrix
|
ims
|
Input
MatrixLayer
|
<optional>
|
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.
It is only available when method:=xyz, multi:=1.
|
Method
|
method
|
Input
int
|
direct
|
Specifies the conversion method.
Option list:
- direct:Direct
- Direct conversion
- xyz:XYZ Columns</nowiki>
- Creates a worksheet with XYZ columns.
|
Data Format
|
xy
|
Input
int
|
xcol
|
This variable is available only when Direct is selected for Method. It specifies how to arrange the data in the target worksheet.
Option list:
- xcol:X across columns
- Matrix values corresponding the same X value will be arranged in a column, while any two matrix values that correspond to different X values will be arranged in different columns. You may also opt to output the X values with the X Values in variable.
- ycol:Y across columns
- Matrix values corresponding the same Y value will be arranged in a column, while any two matrix values that correspond to different Y values will be arranged in different columns. You may also opt to output the Y values with the Y Values in variable.
- noxy:No X and Y
- Matrix X and Y values will not be output.
|
Y Values in First Column
|
ycol
|
Input
int
|
0
|
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
|
0
|
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
|
none
|
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.
Option list:
- none:None
- The matrix X values will not be output.
- row1:First Row
- Outputs the matrix X values to the first row of the target worksheet.
- syspara:System Parameters
- Outputs the matrix X values to the system parameter row of the target worksheet. See the System Parameters variable below.
- userpara:User Defined
- Outputs the matrix X values to a user parameter row of the target worksheet. See the User Defined Parameter variable below.
|
Y Values in
|
ylabel
|
Input
int
|
none
|
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.
Option list:
- none:None
- The matrix Y values will not be output.
- row1:First Row
- Outputs the matrix Y values to the first row of the target worksheet.
- syspara:System Parameters
- Outputs the matrix Y values to a system parameter row of the target worksheet. See the System Parameters variable below.
- userpara:User Defined
- Outputs the matrix Y values to a user parameter row of the target worksheet. See the User Defined Parameter variable below.
|
System Parameters
|
sysparam
|
Input
int
|
p1
|
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.
Option list:
- p1: Parameter 1
- The Parameter 1 column label row.
- p2: Parameter 2
- The Parameter 2 column label row.
- p3: Parameter 3
- The Parameter 3 column label row.
- p4: Parameter 4
- The Parameter 4 column label row.
- p5: Parameter 5
- The Parameter 5 column label row.
- p6: Parameter 6
- The Parameter 6 column label row.
- p7: Parameter 7
- The Parameter 7 column label row.
- p8: Parameter 8
- The Parameter 8 column label row.
- p9: Parameter 9
- The Parameter 9 column label row.
- p10: Parameter 10
- The Parameter 10 column label row.
|
User Defined Parameter
|
userdef
|
Input
string
|
UserDefined
|
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
|
0
|
When there are multiple Matrix objects in a Matrix sheet, you can specify to convert one object only, or all objects.
It is only available when method:=xyz
Option List:
- 0=single:Single Object Only
- Only convert the first matrix object.
- 1=all:All Objects
- Convert all objects in the specified Matrix sheet.
Note: For these two options, the input variable is different.
|
Option
|
option
|
Input
int
|
xconst
|
This variable is available only when XYZ Columns is selected for Method. It specifies how to sort the worksheet values.
Option list:
- xconst: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.
- yconst: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.
|
Trim Missing Values
|
trim
|
Input
int
|
0
|
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
|
[<new>]<new>
|
Specifies the output worksheet.
See the syntax here.
|
Description
The matrix displays a single data set of Z values. It is characterized by:
- numbered columns which are mapped to linearly spaced X values.
- numbered rows which are mapped to linearly spaced Y values.
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.
Examples
/*
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;
Related X-Functions
w2m, r2m, wexpand2m
|