# How can be created a column vector by appending the columns/rows of an array?

User ForumHow can be created a column vector by appending the columns/rows of an array?

How can be created a column vector by appending the columns/rows of an array?

aptech Staff answered 2 years ago

Matrix case
You can turn a matrix in GAUSS into a column vector with either vec or vecr. The vec function will append each of the columns of a matrix in to one column vector, like this:

```x = { 1 2 3,
4 5 6,
7 8 9 };

vec_1 = vec(x);
```

will set vec_1 equal to:

```1
4
7
2
5
8
3
6
9
```

vecr will create a vector by concatenating the rows of the input matrix and then transposing it into a column vector. For example:

```x = { 1 2 3,
4 5 6,
7 8 9 };

vec_2 = vecr(x);
```

will set vec_2 equal to:

```1
2
3
4
5
6
7
8
9
```

N-dimensional array case
You can reshape a GAUSS N-dimensional array into a vector with the vecr function. For example:

```dims = { 2, 3, 4 };
a = areshape(seqa(1, 1, 24), dims);
```

will create the 2x3x4 dimensional array with the following contents:

```Plane [1,.,.]

1     2     3     4
5     6     7     8
9    10    11    12

Plane [2,.,.]

13    14    15    16
17    18    19    20
21    22    23    24
```

Continuing the example:

```v = vecr(a);
```

will create the column vector, v equal to:

```    1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
```

• ### Aptech Systems, Inc. Worldwide Headquarters

Aptech Systems, Inc.
2350 East Germann Road, Suite #21
Chandler, AZ 85286

Phone: 360.886.7100
FAX: 360.886.8922

• ### Training & Events

Want more guidance while learning about the full functionality of GAUSS and its capabilities? Get in touch for in-person training or browse additional references below.

• ### Tutorials

Step-by-step, informative lessons for those who want to dive into GAUSS and achieve their goals, fast.

• ### Have a Specific Question?

Get a real answer from a real person

• Need Support?
• ### Support Plans

Premier Support and Platinum Premier Support are annually renewable membership programs that provide you with important benefits including technical support, product maintenance, and substantial cost-saving features for your GAUSS System or the GAUSS Engine.

• ### User Forums

Join our community to see why our users are considered some of the most active and helpful in the industry!