%code for A
N=500;
r = 6;
center = [2,1,3];
plot3(center(1),center(2),center(3),'ro')
hold on
P = zeros(N,3) ;
for i=1:N
x1 = rand;
x2 = rand;
Px = r*sqrt(x1*(2-x1))* cos(2*pi*x2);
Py = r*sqrt(x1*(2-x1))* sin(2*pi*x2);
Pz = r*(1-x1);
P(i,:) = [Px, Py, Pz]+center;
end
hold on
plot3(P(:,1), P(:,2), P(:,3),'.r')
to
Best Answer