Assume we have nxn binary matrix M. In MATLAB, I want to find the "average" index of points that correspond to 1.
To illustrate, the following examples are shown. A red circle indicates a cell value of 1, all other cell values are 0. The green x is the index that I want to return. A blue line of best fit further illustrates my point.
I am specifically looking for efficient code to do this. Anyone with some simple math skills can calculate this "average" index, but due to MATLAB's loop/iteration-based inefficiencies, I need to write fast code.
