Looking for row of an element in matrix

57 Views Asked by At

I have a $99$x$61$ matrix. The elements are indexed $1-6039$, vertically starting from the top left. So $X[1,1]$ is indexed $1$, $X[2,1]$ is indexed $2,...,X[1,2]$ is indexed $100,..., X[99,61]$ is indexed $6039$. I then have a set of numbers, for example $5300$, $5316$, etc., which are all elements within the matrix. I am looking to find out which row they came from. I'm using Rstudio, but I don't think there are any commands which do this sort of task. I think if I can write a function to calculate using math, the row based on a given element index I would find the result that I'm looking for. However, I am quite stuck at this problem for now. Can anyone help? Thanks!

1

There are 1 best solutions below

0
On

This was found by someone in my school's math club, credit goes to them for finding it.

((n - 1) mod 99) + 1

The issue lies in the nonzero indexing, which he seems to have taken care of. Thanks for the help!