# Command for Matrix with elements besides it [duplicate]

I'm trying to make a new command in LaTeX to put a matrix like that

and i expect that at the end it stands something like this: \newmatrixcommand{#1}{#2}{#3}{#4}. I got close using a composition of commands as follows

\begin{document}
\newenvironment{spmatrix}[1]
{\def\mysubscript{#1}\mathop\bgroup\begin{pmatrix}}
{\end{pmatrix}\egroup_{\textstyle\mathstrut\mysubscript}}

\begin{eqnarray}
\begin{matrix}
a_{1j}\\
a_{2j}\\
a_{3j}
\end{matrix}
\begin{spmatrix}{\;a_{i1} \;\;\; a_{i2} \;\;\; a_{i3}}
a_{11} & a_{12} & a_{13} \\
a_{21} & a_{22} & a_{23} \\
a_{31} & a_{32} & a_{33}
\end{spmatrix}
\begin{matrix}
a_{1j}\\
a_{2j}\\
a_{3j}
\end{matrix}
\end{eqnarray}


That is the result

even trying to change anyhow, i can't get what i supposed to. Any help, will be welcome.