Here's a more "matrix-like" solution:
\documentclass{article}
\usepackage{amsmath,booktabs,xparse}
\ExplSyntaxOn
\DeclareExpandableDocumentCommand{\seps}{m}
{
\noalign{\seps_do_arg:n { #1 } }
\tl_use:N \g_seps_list_tl
}
\tl_new:N \g_seps_list_tl
\cs_new_protected:Npn \seps_do_arg:n #1
{
\tl_clear:N \g_seps_list_tl
\clist_map_inline:nn { #1 }
{ \tl_gput_right:Nn \g_seps_list_tl { \cmidrule(lr){##1--##1} } }
}
\ExplSyntaxOff
\begin{document}
\[
\begin{bmatrix}
I & \textrm{O} \\
\seps{1,2}
\textrm{O} & \textrm{O}
\end{bmatrix}
\begin{bmatrix}
x \\
\seps{1}
u
\end{bmatrix}
=
\begin{bmatrix}
A & B \\
\seps{1,2}
C & D
\end{bmatrix}
\begin{bmatrix}
x \\
\seps{1}
u
\end{bmatrix}
+
\begin{bmatrix}
\mathrm{O} \\
\seps{1}
-y
\end{bmatrix}
\]
\end{document}
You simply give the list of separators you need. It would unfortunately be quite difficult to know how many columns your matrix has.
