Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: Plot Sphere Given Centre Radius

Subject: Plot Sphere Given Centre Radius

From: Rahul Uk

Date: 16 May, 2008 07:16:02

Message: 1 of 4

How can I plot a sphere with center (m,n,o) and radius r???

I m not able to use commands like sphere.

Subject: Re: Plot Sphere Given Centre Radius

From: Ashwini Deshpande

Date: 16 May, 2008 10:51:02

Message: 2 of 4

"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

Subject: Re: Plot Sphere Given Centre Radius

From: Rahul Uk

Date: 16 May, 2008 11:20:03

Message: 3 of 4

"Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in
message <g0joum$7ss$1@fred.mathworks.com>...
> "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
>
Hi,

Tanx a lot....
But why is colorful...cant we make it transparent???

Rahul

Subject: Re: Plot Sphere Given Centre Radius

From: Ashwini Deshpande

Date: 19 May, 2008 05:30:04

Message: 4 of 4

"Rahul Uk" <rauluk23mj@gmail.com> wrote in message
<g0jql3$o73$1@fred.mathworks.com>...
> "Ashwini Deshpande" <vd.ashwini@mathworks.com> wrote in
> message <g0joum$7ss$1@fred.mathworks.com>...
> > "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
> >
> Hi,
>
> Tanx a lot....
> But why is colorful...cant we make it transparent???
>
> Rahul
>

hai,

Instead of surf .. try mesh

Ashwini

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
plot cube Jose Guillermo Guarnizo Marin 24 Jun, 2008 11:23:52
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics