We would need a better explanation of exactly what you want, but I think that the main issues are: 1) you are using sph2cart instead of cart2sph and 2) you are not treating your data as matrices. In general, in Matlab you should not use for loops when you can treat everything as a matrix. Try the following code:
[x,y] = meshgrid(X,Y);
z=repmat(permute(-1:0.02:1,[ 3 1 2]),51,51);
[azimuth,elevation,r] = cart2sph(x,y,z);
Notice that the z was created in a single line, no need to loop. Then with x,y,z you can convert coordinates and then you have your spherical space.
Hope this helps. Try for your problem. If this solves your problem, please accept the answer. I