MATLAB: I’m trying to make a surface 3d plot of this code. But i keep getting just the figure

MATLABsurf

Here is my code so far:
theta= 0:2*pi
ra=1
r=0:ra
x=r*cos(theta)
y=r*sin(theta)
z=sqrt(ra^2-x^2-y^2)
surf(x,y,z,'r')
axis equal
title('Spherical')

Best Answer

I do not get an empty figure, but an arror message:
Error using *
Inner matrix dimensions must agree.
In the line "x=r*cos(theta)" r and theta are vectors of different sizes, such that a multiplication is not defined. Without knowing what you watn to achieve, a suggestion would be wild guessing only.
Related Question