Formula for addressing cell in a Matrix

Hi everyone,

I feel a little stupid as I am sure I covered this in my algebra classes on numerous occasion when I was younger, but I am struggling to find the formula that allows cell addressing in a matrix. For example, how do I find the cell number for the cell that is on column 5, row 4 of an 8x8 matrix ?

Any help would be greatly appreciated. If you need more clarity, let me know.

best,
Joel

Formula? Wouldn't you have defined an array
matrix[8,8]
and then just read/write the elements from there?

getting a value from the matrix:
value_out=matrix[row, column]

putting a value into the matrix
matrix[row,column] = value_in

Do a loop within a loop to access all 64 in one shot, with this code concept:

for (row = 0 to 7)
for (column = 0 to 7)
matrix[row, column]=row*7 + column;
nextcolumn
next row

for (row = 0 to 7)
for (column = 0 to 7)
value = matrix[row, column]
Serial.print (value)
nextcolumn
next row

for (row = 0 to 7)
   for (column = 0 to 7)
        matrix[row, column]=row*7 + column;
   nextcolumn
next row

for (row = 0 to 7)
   for (column = 0 to 7)
        value = matrix[row, column]
        Serial.print (value)
   nextcolumn
next row

Is it Pascal? In C different syntax, but the idea is clear.

matrix[row, column]=row*7 + column;

Why seven?

As others have said above, not sure why you would need this in an Arduino context, but this is what you're asking for I think:

row*8+column

Yes, had 0-7 on the brain, 8 is correct.

I find using the "code concept" vs the actual command makes it easier to visualize, for me anyway:

for (int i=0; i <= 255; i++){
..
}

wildbill:
row*8+column

Thanks so much Bill (and all), this is precisely what I was after. And yes, it's so logical that I feel really stupid. I was making it much more difficult on myself.

In regards to why I would need this, it pertains to the output that I need to address (being an x by x matrix that is addressable via numbers 0 -< total, in my case, 64). The conversation was great here though and it really made me realise that I need to read up on multidimensional arrays a bit. They seem like they could come in real handy!

Thanks again everyone for the help and direction.