Thanks, I had seen that thread. I see that the implementation is the same as what I ended up with.
I’m using linear indices since in the optical simulation I’m running, the physical pixel locations of lenses are being calculated using cartesian coordinates (essentially creating a square grid of points once combined into a meshgrid).
It seems the most convenient way to then index into the new matrix and set the corresponding pixel coordinates to a certain value is to convert into linear indices. Maybe there’s a more Julianic way to achieve the same result, but it works pretty well as it stands.