 # Regarding variable dimension array

Hello:

I just wanted to check, whether it is possible to have variable sized 3D array in Gauss, meaning, I want to have a 3D array where the size of the last two dimension varies by the index of the 1st dimension. I have not used 3D array before in GAUSS, so if its possible to do, I would appreciate if someone could just refer me to the correct link.

Many thanks
Annesha

0

Here is a link to a tutorial on the basics of multi-dimensional arrays in GAUSS. aptech
1,653
0

Just to clarify, so it possible to have a variable dimension array in GAUSS, because as far I have reviewed so far, it seems to me that, its not.

Thanks
Annesha 0

Oh, I see. So instead of having 3 4x5 matrices, for example, you want to have a collection of 3 matrices where the first one might be 2x2, the second one might be 100x5 and the third might be 175x21.

For that, you would probably want to create a structure.

Option 1
If you have only three different matrices that you want to represent, then you could do something like this:

```struct data_center {
matrix num_nodes;
matrix node_ids;
matrix node_vars;
};

struct data_center main;
main.num_nodes = 4;
main.node_ids = { 1012,
1043,
1104,
1009 };
main.node_vars = { 37 0 2,
34 1 4,
35 0 1,
33 0 0 };
```

You can refer to each member of the structure by name and each member can be any size that you want.
Option 2
However, if you may not have always exactly 3 or you would rather refer to them by index instead of name, you can create a very simple structure that just has a matrix member and then make an array of them like this:

```struct var_array {
matrix x;
};

struct var_array a;
a = reshape(a, 3, 1);
a.x = { 1 2,
3 4 };
a.x = { 7 8 9 };
a.x = { 10,
11,
12 };
``` aptech
1,653
0

Thank you much, this is very helpful.

Annesha ### Have a Specific Question?

Get a real answer from a real person

### Need Support?

Get help from our friendly experts.

### Try GAUSS for 14 days for FREE

See what GAUSS can do for your data