# 2.2.1.3 w2m

Worksheet : Convert to Matrix : Direct...

## Brief Information

Convert entire worksheet to matrix

This feature is updated in 8.0 SR4. For more details, please refer to Release Notes.

## Command Line Usage

 1. w2m iw:=[Book1]Sheet1! xy:=noxy; 

2. w2m trim:=1; 

3. w2m iw:=[Book1]Sheet2; 

4. w2m om:=[MBook1]MSheet2; 

5. w2m [Book2]1 [MBook3]MSheet2!Mat(1); 

6. w2m iw:=[book1]sheet1! xy:=xcol xlabel:=param param:=L; 

## Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Input Worksheet iw

Input

Worksheet

<active>
Specify the worksheet to be converted
Data Format xy

Input

int

noxy
Specify the X and Y coordinates

Option list:

• xcol:X across columns
0. Specify that the X coordinates will be from row values of the source worksheet, across the columns.
• ycol:Y across columns
1. Specify that the Y coordinates will be from row values of the source worksheet, across the columns.
• noxy:No X and Y
2. Directly convert the entire worksheet without specifying X and Y coordinates. X and Y coordinates will be integer values.
X Values in xlabel

Input

int

Available when X across columns is selected from Data Format. It can be the worksheet first data row or a column label row.

Option list:

• none:None
Use matrix column indices as X coordinates.
• row1:First Data Row
Use the values of the first data row as X coordinates.
• param:Use Parameter
Use the values of a column label row as X coordinates.
Y Values in First Column ycol

Input

int

0
Available when X across columns is selected from Data Format. Check to use the first column values as Y coordinates.
Y Values in ylabel

Input

int

Available when Y across columns is selected from Data Format. It can be the worksheet first data row or a column label row.

Option list:

• none:None
Use matrix row indices as Y coordinates.
• row1:First Row
Use the values of the first data row as Y coordinates.
• param:Use Parameter
Use the values of a column label row as Y coordinates.
X Values in First Column xcol

Input

int

0
Available when Y across columns is selected from Data Format. Check to use the first column values as X coordinates.
Column Label param

Input

string

This is only available when Column Label is selected from X Values in or Y Values in. Specify the label row to use as the X or Y coordinates using its Label Row character. Please refer to Column Label Row Characters for the single character of each column label row.
Even Spacing Relative Tolerance(%) tol

Input

double

5
Tolerance used to check for even spacing.
Use Linear Fit Estimate for Coordinates lr

Input

int

0
This checkbox specifies whether or not to use linear fit estimate for coordinates.
Trim Missing trim

Input

int

1
Determine whether to trim the missing rows or columns
Output Matrix om

Output

MatrixObject

<new>
Specify the output matrix

See the syntax of Output_Notations.

## Description

This X-Function is capable of converting worksheet data into matrix.

The matrix displays a single data set of Z values and 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 below). To display X and Y values (right figure below), select View: Show X/Y from menu.

If convert the worksheet without specifying X or Y values, Origin will convert worksheet values directly to matrix and assign the matrix coordinates automatically. To reset the coordinates, select Matrix: Set Dimension/Labels from menu. If the worksheet contains X or Y coordinates information in worksheet cells or worksheet column label rows, which organized like:

The new matrix X and Y coordinates can be set by these values. (Note: the X and Y coordinate values should be even spaced).

For example:

1. If X data values are in the 1st row and Y data values are in the 1st column, the X-Function creates a (columns -1) by (rows -1) matrix of Z values like:
2. If Y values in the worksheet label rows and X values are not specified, the X-Function creates a matrix like:

Note that in this case, the output matrix is transposed during conversion.

If there are missing values for entire rows or columns in the worksheet, check the Trim Missing box will trim the missing row or column.

## Examples

• Code Sample
/*
This example shows how convert worksheet data into matrix.
The sample data is exe_path\Samples\Matrix Conversion and Gridding\DirectXY.dat.
1. Load data to a new created workbook.
2. Convert worksheet data into matrix, using first row as X and first column as Y.
*/
// Get sample data
fn$= system.path.program$ + "Samples\Matrix Conversion and Gridding\DirectXY.dat";
newbook;
impASC fn\$;

// Convert worksheet data into matrix, using first row as X and first column as Y
w2m xy:=0 xlabel:=row1 ycol:=1;

## Related X-Functions

Keywords:coordinates, labels