The description of the MRI signal from the magnetization vector
You always measure the (vector) sum over all magnetization vectors in your object, $S(t) = \sum\limits_{(x,y)} M(x,y,t)$. This sum gives you an amplitude and a phase. That is your measured signal.

From the gradients that you simulate, you know the $k$-space position as a function of time, i.e. you have $k(t)$. Now you sample your signal at certain points and sort the signals $S(t_n)$ into the respective $k(t_n)$-space. A FFT should now convert your $k$-space into the image again.