# Matrix operations - filter out diagonal elements of a matrix using multiplication operation

Is there a way to filter out only the diagonal elements of a matrix $A$, by doing a matrix multiplication with some matrix $B$ like this:

$A*B$ = $D$

where $D$ matrix contains only diagonal elements of $A$?

-

No, unless $A$ is $1\times1$. Try $A=\pmatrix{1&0\\ 1&0}$.