# Constructing a Hankel matrix for n4sid with multiple inputs\outputs

I am trying to construct a Hankel matrix to write my own code for n4sid algorithm (page 47 and 22).

$$\mathcal{H}= \underbrace{\begin{pmatrix} U_{0|2i-1}\\ Y_{0|2i-1} \end{pmatrix} / \sqrt{j} }_{2(m+l) i\times j}$$

The problem is I'm having a hard time visualizing how the matrix should be constructed.

a normal hankel matrix constructed from a single vector looks like this:

$$\mathcal{H}_a =\begin{pmatrix} a & b & c & d & e \\ b & c & d & e & f \\ c & d & e & f & g \\ d & e & f & g & h \\ e & f & g & h & i\end{pmatrix}$$

so If i have two input vectors and one output vector:

$$\vec{u}_a = \begin{bmatrix} u_1 & u_2 & u_3 & ... & u_n \end{bmatrix}$$
$$\vec{u}_b = \begin{bmatrix} u_1 & u_2 & u_3 & ... & u_n \end{bmatrix}$$

$$\vec{y}_a = \begin{bmatrix} y_1 & y_2 & y_3 & ... & y_n \end{bmatrix}$$

I understand how to construct a matrix for a singular output and input vector, that would be straight forward. The problem is if there are multiple inputs and multiple outputs, that is where the clarity breaks down for me. Because if each element of the Hankel matrix becomes a vector (or an element of a vector) it wouldn't be square. Another problem is if you have say two inputs and only one output, then I suppose you zero pad the output to keep everything symmetrical, and then truncate the state space equations (which would be square but with zeros after identification, then you truncate the zeros out).

How would I construct both input and output Hankel matrices from those vectors?

If I only have one output and two inputs do I fill the Hankel matrix with values?