Hello Lee -

The ImageJ Macro language (IJM) doesn’t support 2D arrays, but

ImageJ itself does.

The best “workaround” would be to switch to jython (python) or one

of the other scripting languages supported by ImageJ (or use java,

the language in which ImageJ is written).

If you wish to stick with IJM, there are [Edit] three common workarounds:

[Edit] Zero: Use “index arithmetic” to pack a 2D array into a 1D array.

Thus:

```
for (i = 0; i < nRows; i++) {
for (j = 0; j < nColumns; j++) {
matrix_entry_ij = matrix[i * nColumns + j];
// process matrix_entry_ij
}
}
```

This is an old-school multi-dimensional matrix idiom.

First: Use a bunch of row variables, each of which is an IJM array

containing the fields in that row, and access them with a big nested

if statement. Thus: `row1`

, `row2`

, …, `row213`

, and

```
for (i = 1; i <= 213; i++) {
if (i == 1) // process row1
else if (i == 2) // process row2
...
else if (i == 213) // process row213
}
```

Of course, this will be rather unwieldy, given the size of your matrix.

Second: Pack one of your dimensions into strings that you then

parse. Thus, `matrix`

is an IJM (1D) array, and

```
matrix[0] = "1.1, 1.2, ..., 9.9";
...
for (i = 0; i < lengthOf (matrix); i++) {
vals = split (matrix[i], ",");
for (j = 0; j < lengthOf (vals); j++) {
matrix_entry_ij = vals[j]
// process matrix_entry_ij
}
}
```

This is also somewhat annoying, but works.

([Edit] You can also use the Results Table as a 2D array, but it has

named columns, rather than indexed columns, so you’re not really

any better off than using a bunch of named row (or named column)

variables.)

My recommendation would be jython, rather than one of these

workarounds.

Thanks, mm