% Script to generate a sphere in 3D
% Minas Spetsakis, Nov. 2017
res = 50;
phi = linspace(0,2*pi,res);
theta = linspace(-pi/2,pi/2,res);
X = zeros(res);
Y = zeros(res);
Z = zeros(res);

for i=1:res
    for j=1:res
        X(i,j) = cos(phi(i))*cos(theta(j));
        Y(i,j) = sin(phi(i))*cos(theta(j));
        Z(i,j) = sin(theta(j));
    end;
end;
surf(X,Y,Z);
daspect([1 1 1]);