How do I find transfer functions from a state space representation? Suppose I have a MIMO system in state space representation, for example:

$A=\begin{bmatrix}
1 &amp;2  &amp;3 \\ 
 4&amp;5  &amp;6 \\ 
 7&amp;8  &amp;9 
\end{bmatrix}$ 

$B=\begin{bmatrix}
2 &amp;3 \\ 
 5&amp; 7\\ 
9 &amp; 1
\end{bmatrix}$

$C=\begin{bmatrix}
6 &amp;7  &amp;11 
\end{bmatrix}$

$D=0$

I have used random number to fill these matrices. I am using Matlab. Now, suppose I want to find the transfer function from the input $u$ to the to an output $x_2$ for example, how is it possible to do this? 

I know that I can from this matrix create the state space representation. So, suppose I want the state space representation of a plant, I would do this:

G = ss(A,B,C,D)


and if I want to get the transfer function from it I could do :

G = ss2tf(A,B,C,D)


and so from here I could plot the frequency response:

bode(G)


but now, suppose I want to obtain the transfer function from the disturbance to the output, or the transfer function from the input $u$ to the output, how can I do this ?

[EDIT] For example, how do I obtain the sensitivity function from a state space representation of a MIMO system? Or the control sensitivity function?
or the transfer function from the input  to the output, how can I do this ?


Is that not what your $G$ is?  If you want to find the transfer function from just one element of $u$ to the output, then either delete the columns of $B$ that don't pertain to that element of $u$ and get your transfer function, or just look at the column of the transfer function that matches the element you want.


  but now, suppose I want to obtain the transfer function from the disturbance to the output, 


Then you would make a column for $B$ (or make a new $B$) that represents the effect that the disturbance has on the system, and extract the transfer function from that.

Edit

I neglected to include the actual math that Matlab is doing under the hood.  This is twice bad -- once because I did it, and twice because I really don't like people who just push the Matlab buttons without understanding what's actually going on.

If you have a system in state space representation:
$$\begin{split}x_k = A x_{k-1} + B u_k \\ 
y_k = C x_{k-1} + D u_k\end{split}$$ then you can take the $z$ transform:

$$\begin{split}X = A\ X(z) z^{-1} + B\ U(z) \\ 
Y = C\ X(z) z^{-1} + D\ U\end{split}$$
Then (leaving out steps, the grader will have words with me, but it's all linear algebra) you can solve for $X/U$:
$$\frac{X(z)}{U(z)} = C \left(I z - A\right)^{-1} B + D$$

Note that a nice thing about doing it this way is that if $B$ and $C$ happen to be single column and single row, then you get a nice, traditional scalar transfer function -- but if they're multi-dimensional, you get a very natural matrix representation for a transfer function that just drops naturally out of the math.