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;

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Matrix im

Input

MatrixObject

<active>

Specifies the source matrix.

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: Parameters
    The Parameters column label row.
  • p2: Parameters 2
    The Parameters 2 column label row.
  • p3: Parameters 3
    The Parameters 3 column label row.
  • p4: Parameters 4
    The Parameters 4 column label row.
  • p5: Parameters 5
    The Parameters 5 column label row.
  • p6: Parameters 6
    The Parameters 6 column label row.
  • p7: Parameters 7
    The Parameters 7 column label row.
  • p8: Parameters 8
    The Parameters 8 column label row.
  • p9: Parameters 9
    The Parameters 9 column label row.
  • p10: Parameters 10
    The Parameters 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.

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.

M2w image12.gif

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.

M2w image13.gif

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:

M2w image14.gif

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:

M2w image15.gif

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.

M2w image16.gif

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.

M2w image17.gif

Examples

  • Code Sample
/*
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