Path: news.mathworks.com!not-for-mail
From: "Ashwini Deshpande" <vd.ashwini@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Plot Sphere Given Centre Radius
Date: Fri, 16 May 2008 10:51:02 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 25
Message-ID: <g0joum$7ss$1@fred.mathworks.com>
References: <g0jcbi$6od$1@fred.mathworks.com>
Reply-To: "Ashwini Deshpande" <vd.ashwini@mathworks.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210935062 8092 172.30.248.38 (16 May 2008 10:51:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 16 May 2008 10:51:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1101624
Xref: news.mathworks.com comp.soft-sys.matlab:468808


"Rahul Uk" <rauluk23mj@gmail.com> wrote in message
<g0jcbi$6od$1@fred.mathworks.com>...
> How can I plot a sphere with center (m,n,o) and radius r???
> 
> I m not able to use commands like sphere. 

Hai,

One of the method is:
[x,y,z] = sphere(30);
surf(x+a, y+b, z+c) % where (a,b,c) is center of the sphere

and second method is:
r=1;
phi=linspace(0,pi,30);
theta=linspace(0,2*pi,40);
[phi,theta]=meshgrid(phi,theta);

x=r*sin(phi).*cos(theta);
y=r*sin(phi).*sin(theta);
z=r*cos(phi); 

Hope it helps,
Ashwini