You would get that error if "IDX" or "i" are vectors that are larger than the size of the second dimension of the Input matrix.
To phrase that another way, if you have logical indexing with a logical vector that is larger than the dimension being accessed, then you will get the "Index exceeds matrix dimensions" error .
