<s>[INST] Find a general control and then show that this could have been achieved at x2 Determine the general form of $u_0, u_1 ~\text{and} ~ u_2$ if a system of difference equations of the form
$$x_{n+1} = Ax_n  + Bu_n,$$
where:
$$A = \begin{pmatrix}
  3 & 2 & 2  \\
  -1 & 0 & -1 \\
   0 & 0 & 1
  \end{pmatrix}$$
and:
$$B = \begin{pmatrix}
  0 & 0  \\
  0 & 1 \\
  1 & 0
  \end{pmatrix}$$
is to be controlled for $x_0 = 0 ~ to ~ x_3 = [2, 1, 2]^T$ .
Show this target could have been achieved at  $x_2$ 
Solution
So far I have caculated the controlability matrix to be
$$
C
=\begin{pmatrix}
0&0&2&2&6&6\\
0&1&-1&0&-3&-2\\
1&0&1&0&1&0
\end{pmatrix}.
$$
Thus the system is controlable
Now putting Cv=x3 i have the 3 equations
$$
2c+2d+6e+6f=2\\
b-c-3e-2f=1\\
c+e+f=2\\
$$
which i have then put into augmented matrix row echleon form which i have found to be
$$
a-d-2e-3f=1\\
b+d+f=2\\
c+d+3e+3e=1\\
$$
How do I now solve with so many unknowns? also can you please check my working so far is correct. many thanks
 [/INST] First of all we have forall $n\in N:$ $u_{n}\in R^{2}$.
So let 
$$u_{0}=(u_{0,1},u_{0,2})^{t}$$ be given as well as $x_{0}=0$.
Then we get
$$
x_{1}=Ax_{0}+Bu_{0}=0+(0,u_{0,2},u_{0,1})^{t}$$
Again plugging this into the recursion we obtain
$$
x_{2}=Ax_{1}+Bu_{1}=A(0,u_{0,2},u_{0,1})^{t}+B(u_{1,1},u_{1,2}).$$
This has by assumption to be $x_{3}$ so you get $4$ variables to determine.
The system is underdetermined, but this should be no problem since you only have to solve the linear equation
$$x_{3}=A(0,u_{0,2},u_{0,1})^{t}+B(u_{1,1},u_{1,2})$$
with respect to $u_{0,1},u_{0,2},u_{1,1},u_{1,2}$.
An update to your problem. The Kalman matrix $C$ is correct. Now we want to find the vector $u:=(u_{0,1},u_{0,2},u_{1,1},u_{1,2},u_{2,1},u_{2,2})^{t}\in R^{6}$ such that
$$Cu=x_{3}.$$
We can write this in matrix vector representation as
$$
\begin{pmatrix}
0&0&2&2&6&6&|2\\
0&1&-1&0&-3&-2&|1\\
1&0&1&0&1&0&|2
\end{pmatrix}
$$
By changing rows and dividing by 2
$$
\begin{pmatrix}
1&0&1&0&1&0&|2\\
0&1&-1&0&-3&-2&|1\\
0&0&1&1&3&3&|1\\
\end{pmatrix}
$$
This system is in echelon form. So we first determine one specifical solution, for instance 
$$u^{*}=\begin{pmatrix}
2\\1\\0\\1\\0\\0\end{pmatrix}
$$.
Next we need the KERNEL of the matrix, that is the elements
$$\operatorname{ker}(C):=\{x\in R^{6}: Cx=0\}.$$ In matrix vector representation this is
$$
\begin{pmatrix}
1&0&1&0&1&0&|0\\
0&1&-1&0&-3&-2&|0\\
0&0&1&1&3&3&|0\\
\end{pmatrix}
$$
Since this matrix has $\operatorname{Rank}(C)=3$, we have to find $3$ vectors, linear independent and satisfying the kernel condition: The vectors
$$v_{1}=\begin{pmatrix}
2\\0\\-3\\0\\1\\0
\end{pmatrix}
\quad
v_{2}=\begin{pmatrix}
0\\2\\0\\-3\\0\\1\end{pmatrix}
\quad
v_{3}=\begin{pmatrix}
1\\-1\\1\\-1\\-2\\2\end{pmatrix}
$$
do the job, so they generate the kernel of $C$. Altogether we have as solution
$$
u\in\{u^{*}+\lambda v_{1}+\mu v_{2}+\sigma v_{3}, \lambda,\mu,\sigma\in R\}.
$$
So if you pick a control vector $u$ in this set, you control the state to $x_{3}$.
</s>