I found out that in matlab there is a function called bin2gray which converts from binary to gray coding, but as i saw, i have a results differ from what i expect !!! where the matlab results for 16QAM is
while in one of the books such as "Single- and Multi-carrier Quadrature Amplitude Modulationrinciples and Applications for Personal Communications, WLANs and Broadcasting" by L. Hanzo, W.T. Webb, T. Keller , the constellation is
and in a website "http://www.dsplog.com/2008/06/01/binary-to-gray-code-for-16qam/" the mapping is