 # 3D to 2D Array

Hi all,

When accessing an element of a 3D array this way :

` myMat = R1[1,.,.] `

In order to get a 2D (x by y) array, Gauss resturns a 3D (1 by x by y) instead.

How can I get this (1 by x by y) array to a 2D (x by y) array (in order to make matrix calculation : `myMat*scndMat` ?

0

The matrix multiplication should still work, for example:

```//create 2x4x3 array of random normal numbers
tmp = rndn(2*4*3, 1);
a = areshape(tmp, 2|4|3);

//create 3x4 random matrix
b = rndn(3,4);

//print results of matrix multiply
print b*a[1,.,.];
```

However, the result will be a 3-dimensional array that is 1x3x3. You can convert an array to a matrix with the GAUSS function arraytomat. For example, we could change the matrix multiply line to this:

```a_mat = arraytomat(a[1,.,.]);

//print results of matrix multiply
print b*a_mat;
```

Or equivalently and more compactly:

```//print results of matrix multiply
print b*arraytomat(a[1,.,.]);
``` aptech
1,548

### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.