Find indices or corresponding values except given indices

One way is to work with logical indices, i.e. boolean flags:

A = [1 2; 3 4]
flags = A .== 1
A[.!flags]

Another way is using Not from the InvertedIndices package:

using InvertedIndices
A = [1 2; 3 4]
indices = findall(a -> a == 1, A)
A[Not(indices)]
3 Likes