Plotting spherical coordinate system in Matlab
<p>I want to draw a spherical coordinate system in Matlab.</p>

<p>This is the kind of image I'd like to create:</p>

<p><a href="https://i.stack.imgur.com/o147q.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/o147q.gif" alt="This is what I&#39;d like to create in matlab."></a></p>

<p>Could someone give me some hints? (So far I've plotted the cartesian coordinates)</p>

<p>Here is what I have tried myself:</p>

<pre><code>hold on
x0=0;
y0=0;
z0=0;

plot3(x0+[0, 1, nan, 0, 0, nan, 0, 0], y0+[0, 0, nan, 0, 1, nan, 0, 0], z0+[0, 0, nan, 0, 0, nan, 0, 1] )       
text([x0+1, x0, x0], [y0, y0+1, y0], [z0, z0, z0+1], ['X';'Y';'Z']);

r=0.5;
[x,y,z] = sphere(100); 
hsurf = surf(x*r, y*r, z*r);
axis equal;
</code></pre>