%% Specify Sphere Radius and Location
% Specify the radius and location of a sphere by modifying the returned X, Y, and Z coordinates.
% Define X, Y, and Z as coordinates of a unit sphere.

[X,Y,Z] = sphere;

%
% Plot the unit sphere centered at the origin.

surf(X,Y,Z)
axis equal

%
% Define X2, Y2, and Z2 as coordinates of a sphere with a radius of 5 by multiplying the coordinates of the unit sphere. Plot the second sphere, centering it at (5,-5,0).

hold on
r = 5;
X2 = X * r;
Y2 = Y * r;
Z2 = Z * r;

surf(X2+5,Y2-5,Z2)

% Copyright 2019 The MathWorks, Inc.