How to remove the diagonal of a matrix I just don't need to extract the diagonal of a matrix, but I need to remove it so if I have a matrix of size $N\times N$:
$$
    \begin{bmatrix}
    x_{11} & x_{12} & x_{13} \\
x_{21} & x_{22} & x_{23} \\
x_{31} & x_{32} & x_{33} \\
    \end{bmatrix}
$$
I end up with a matrix of size $N\times(N-1)$:
$$
    \begin{bmatrix}
    x_{12} & x_{13} \\
x_{21}  & x_{23} \\
x_{31} & x_{32} \\
    \end{bmatrix}
$$
If it is useful, in my case all the rows of the matrix are equal, so the question can be also how to transform a vector:
$$
    \begin{matrix}
   [ x_{1} & x_{2} & x_{3} ]
    \end{matrix}
$$
Into the matrix:
$$
    \begin{bmatrix}
    x_{2} & x_{3} \\
x_{1}  & x_{3} \\
x_{1} & x_{2} \\
    \end{bmatrix}
$$
Any matrix mapping or help is really appreciated! Thanks a lot!
 A: If you take the vector as a $1\times 3$ matrix $v = \begin{pmatrix} 
x_1 & x_2 & x_3
\end{pmatrix}$ then
$$\begin{pmatrix} 
x_2 & x_3 \\
x_1 & x_3 \\
x_1 & x_2
\end{pmatrix}
=
\begin{pmatrix} 
1 \\
0 \\
0
\end{pmatrix}
v
\begin{pmatrix} 
0 & 0 \\
1 & 0 \\
0 & 1
\end{pmatrix}
+\begin{pmatrix} 
0 \\
1 \\
0
\end{pmatrix}
v
\begin{pmatrix} 
1 & 0 \\
0 & 0 \\
0 & 1
\end{pmatrix}
+\begin{pmatrix} 
0 \\
0 \\
1
\end{pmatrix}
v
\begin{pmatrix} 
1 & 0 \\
0 & 1 \\
0 & 0
\end{pmatrix}
$$
But I doubt this turn out to be useful. I thing you'll do better just using the matrix you want instead of a representation through matrix operations.
A: You can always select an arbitrary element of a matrix by multiplying by the row number matrix from the left and the column number matrix from the right (these matrices have the form $diag(0,0...0,1,0...0)$ with one on the spot of the row/column entry). Example for extracting the element in the first row, second column:
$$
\pmatrix{1 & 0 & 0\\ 0 & 0 & 0\\ 0 & 0 & 0}\pmatrix{a & b & c\\ d & e & f\\ g & h & i}\pmatrix{0 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 0} = \pmatrix{0& b & 0\\ 0 & 0 & 0\\ 0 & 0 & 0}.
$$
So add up the non diagonal elements and you will get the matrix with zeroes on the diagonal as follows:
$$
\pmatrix{0& b & c\\ d & 0 & f\\ g & h & 0}.
$$
This should already bring you closer to what you need.
For your second scenario you can "tile" the vector such that you get an $N\times N$ matrix with $N$ copies of the row vector in question.
Inspiration from: Other Question
