2.2.12 m2v

Brief Information

Copy a single column, row, or entire matrix to a worksheet column

Command Line Usage

1. m2v im:=[Mbook1]MSheet1!mat(1); // Transfer the first row of a matrix to a worksheet column.

2. m2v method:=m2v direction:=col; // Transfer the whole matrix to a worksheet column. Append by column.

3. m2v method:=row2v ox:=[book1]Sheet1!col(2); // Transfer the first row of a matrix to a specified column.

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 input matrix. The default is the active matrix object.

Method method

Input

int

col2v

Specifies method to convert the matrix.
Option list

  • col2v:Copy a Column to Vector
    Copies a column in matrix to a vector.
  • row2v:Copy a Row to Vector
    Copies a row in matrix to a vector.
  • m2v: Copy all Matrix to Vector
    Copies all elements in the matrix to a vector.
Index of Column/Row index

Input

int

1

This variable is available only when Method is either Copy a Column to Vector or Copy a Row to Vector. It specifies the index of the column/row that will be copied to a vector.

Direction direction

Input

int

row

This variable is available only when Method is Copy all Matrix to Vector. It specifies the direction for copying the matrix elements.
Option list

  • row:By Row
    The matrix elements will be copied row by row.
  • col:By Column
    The matrix elements will be copied column by column.
Output ox

Output

vector

<new>

Specifies the output vector.

Description

This X-Function converts a matrix or part of a matrix to a vector.


Examples

This example unwraps a matrix and outputs it into a column in worksheet:

// Create a matrix
newbook mat:=1;
// fill the matrix cell with random numbers
matrix -v rnd();
// convert the matrix into a vector and output to a column
m2v method:=m2v ox:=[<new>]Sheet1!col(1);

Related X-Functions

m2w, v2m


Keywords:convert, vector