08-02-2016 10:16 AM
Here you go.
08-02-2016 10:34 AM
sorry but i want to calculate the center mass of the matrix for element '1'
08-02-2016 10:36 AM
Did you enter 1 in element?
08-02-2016 05:25 PM
This code should work:
The result is 0-indexed, so change it if you need to.
How it works:
1. Read in the sample array
2. Loop through every row, and pass the current row index into another for loop, call this i
3. Loop through every column of the current row, the index is j.
4. If the element at i, j is equal to the search element, index it out using a conditional indexing tunnel.
5. Concatenate all indexed tunnels, which essentially builds a master list of all the rows/columns where we found the search element
6. Calculate the mean index for both.
I got a mean row of 3.17, mean column of 4.52
08-03-2016 04:53 AM
08-03-2016 04:57 AM