This question already has an answer here:
Here's a simple example. Suppose we want to find the off-diagonal matrix of m:
This can be solved fairly simply by extracting a list of the diagonal elements, re-creating the diagonal matrix from these, and removing them from the full matrix to get the off-diagonal elements:
m - DiagonalMatrix[Diagonal[m]]
Now, this was a fairly simple solution to the given problem, but what I'm wondering is if there is a way to write something akin to
(Identity - DiagonalMatrix@Diagonal)[m]
To get the same result. In this simple example, not much would be gained by doing this, but I just thought it could be interesting in more complicated problems and help make the code resemble more closely the underlying mathematics in some cases.