1) "alpha" and "Distance" are both (2-dimensional) 9 x 9 matrices.
1a) Accessing elements of such a matrix require the use of TWO indices (row and column). You are using just one index, so Prime can't possibly know which element you mean or if you mean a whole column or row.
1b) "length( )" can only be used to get the number of elements in a (1-dimensional) n x 1 matrix = column vector. For 2-dimensional matrices you can use the functions "rows( )" and "cols( )" to get the number of rows and columns.
2) Prime does not support 3-dimensional structures so you can't use three indices like in
If you really need a structure like a 9 x 24 x 9 "matrix", you could create nested matrices. Perhaps a 9 x 1 matrix (= column vector) which consists of 9 matrices with dimension 24 x 9. Or a 9 x 24 matrix where each element is a 9 x 1 vector. Depends on your needs.
3) Loops in programs are created using ranges! If you write
then j takes only ONE value (in this case 24). If you want to run j from the first index (1 in your sheet) to the last (24 in case of Beta) you would have to write
. Using "last" instead of "length" assures that the program also works OK if the system variable ORIGIN is set to something different than 1.
Not sure what exactly you are trying to create, but maybe this function can be of help:

It creates a 9x9 matrix for every of the 24 values in Beta and collect them in a 24 x 1 vector:

Showing just the first two ...

Of course you can access individual elements the usual way, here the matrix you get for Beta with index 10:
