## Converting matrix to vector data and vector to matrix data

**Download**

# Description

Overview: This model illustrates how to load values from a matrix into a vector and from a vector into a matrix. This can be done using GoldSim's vector and matrix constructors. The examples show how a target vector can be loaded from a matrix either by row or by column and likewise how a target matrix can be loaded by row or column from a vector.

Examples: In Example 1, a vector of size 15 is loaded from a 4x5 matrix by rows. The target vector is then used as a source to load a 4x5 matrix by rows. The last row of the target matrix is filled with 0s since there are not enough values in the source vector.

In Example 2, a vector of size 25 is loaded from a 4x5 matrix by rows. The last 5 entries in the target vector are filled with 0s since there are not enough values in the source matrix to fill the vector. This vector is then used as a source to load a 4x5 matrix by rows. The resulting matrix is identical to the original source matrix.

In Example 3, a vector of size 15 is loaded from a 4x5 matrix by columns. The target vector is then used as a source to load a 4x5 matrix by columns. The last column and one entry in the 4th column are filled with 0s since there are not enough values in the source vector to fill the matrix.

In Example 4, a vector of size 25 is loaded from a 4x5 matrix by columns. The last 5 entries in the target vector are filled with 0s since there are not enough values in the source matrix to fill the vector. This vector is then used as a source to load a 4x5 matrix by columns. The resulting matrix is identical to the original source matrix.

# Additional Information

## Keywords

vector, matrix, array, constructor

## Categories

GoldSim Features & Capabilities, Basic Function Elements, Arrays