title: using the Error using surf---X, Y, Z, and C cannot be complex
body: <p>I have been trying to plot a spherical surface using the routine below but i get this error message "using the Error using surf (line 75)
  X, Y, Z, and C cannot be complex" each time i try to run this code.
  I need your opinions to solve this problem.
  Thanks</p>
  
  <p>Error in draw_sph (line 38)
  surf(x,z,y,'facecolor','interp',...</p>
  
  <pre><code>     D=[50,0,0];
       c=1/10;
       k=1;
       Vertex=[0 0 0];
  
  
        M=5;
        n=2^(M-1);
  
        phi =(linspace(0,2*pi,n));
        r=(linspace(0,D(1),n))';
  
        x = r*cos(phi)+Vertex(1);
        y = r*sin(phi)+Vertex(2);
        z = (c*((r*cos(phi)).^2+(r*sin(phi)).^2))./
             (1+sqrt(1-(1+k)*c^2*((r*cos(phi)).^2+(r*sin(phi)).^2)))+Vertex(3);
  
  
  
       surf(x,z,y,'facecolor','interp',...
       'edgecolor','none',...
       'facelighting','phong'); 
  
  
       axis equal
       axis tight
       %camlight left
       alpha(.33)
  
  
  
       draw=1;
  </code></pre>