Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Plot a torus
Date: Sun, 13 Jun 2010 18:29:04 +0000 (UTC)
Organization: Universit&#228;tsSpital Z&#252;rich
Lines: 37
Message-ID: <hv381g$a3m$1@fred.mathworks.com>
References: <hv33sb$300$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1276453744 10358 172.30.248.35 (13 Jun 2010 18:29:04 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 13 Jun 2010 18:29:04 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 11
Xref: news.mathworks.com comp.soft-sys.matlab:644593

"kawak " <kbenjamin@hotmail.fr> wrote in message <hv33sb$300$1@fred.mathworks.com>...
> Hello,
> 
> I would like to plot a basic torus on matlab. 
> 
> Here is my code:
> 
> u=0:0.1:2*pi;
> v=0:0.1:2*pi;
> 
> a=2;
> b=1;
> 
> X=(a+b.*cos(v)).*cos(u);
> Y=(a+b.*cos(v)).*sin(u);
> Z=b.*sin(v);
> 
> surf(X,Y,Z)
> 
> But it didn't work. Do you know why? 
> 
> Thank you very much
> 
> Benji

one of the solutions

     a=5;
     c=10;
     [u,v]=meshgrid(0:10:360);
     x=(c+a*cosd(v)).*cosd(u);
     y=(c+a*cosd(v)).*sind(u);
     z=a*sind(v);
     surfl(x,y,z)
     axis equal;

us