How do I find transfer functions from a state space representation?
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.