Given a matrix where there is some varying number of columns and rows I need to calculate for any given 'tile' its ROW and COLUMN. Example, a matrix that has 3 columns and 3 rows will have a total of 9 tiles and tile#4 will be in the 1st column, 2nd row, whereas if it were a 4X4 matrix tile#4 would be in the 4th column, first row.  So the knowns at any given time are tileNumber, numberOfRows, and numberOfColumns.  From those variables I want a calculation for the associated column and row for any given tile.  Column = SomeFormula(tileNumber,NumberofRows)

Row = SomeFormula(tileNumber,NumberofColumns)

Example 3X3 matrix with associated tileNumbers.

1 | 2 | 3

4 | 5 | 6

7 | 8 | 9

 

in Algebra 1 Answers by

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

1 Answer

Let N=tile number, R=row number of the tile, C=column number of the tile. nR=number of rows, nC=number of columns. The matrix contains nR*nC tiles. The tiles are numbered from 1 to nR*nC from left to right on each row.

N-1=nC(R-1)+C-1 relates N, nC and R. Note that nR is absent. The reason for the -1's is that numbering starts from 1 rather than zero. The algorithms for calculating R and C need to cater for N>nR*nC; if this happens R and C could be returned as zero; similarly if N is negative or zero.

To find R, divide N-1 by nC to give a quotient and remainder. Add 1 to the quotient to get R and add 1 to the remainder to get C.

Take the 3*3 matrix. nC=nR=3, nC*nR=9. N must be between 1 and 9. Let N=5, so N-1=4. Divide 4 by 3 to give 1 remainder 1. So R=1+1=2 and C=2. Take a 7*5 matrix, nR=7 and nC=5. Let N=21, N-1=20. (N-1)/5=4 rem 0. So R=5 and C=1. But if nR=5 and nC=7 and N=21, we have 20/7=2 rem 6, so R=3 and C=7.

 

by Top Rated User (1.2m points)

Related questions

Welcome to MathHomeworkAnswers.org, where students, teachers and math enthusiasts can ask and answer any math question. Get help and answers to any math problem including algebra, trigonometry, geometry, calculus, trigonometry, fractions, solving expression, simplifying expressions and more. Get answers to math questions. Help is always 100% free!
87,516 questions
100,279 answers
2,420 comments
731,672 users