beginer| basic problem with bad plot results

Hello, I just started using matlab and I got stucked with questions abou using plot and plot3 functions.
one example is
(a=,b=,c=,<t>)
x=f(a,b,c,d), y=f(a,b,c,d), z=f(a,b,c,d)
the result should be toroidal spiral..
here is my program:
a=0.2;
b=0.8;
c=20;
t=linspace(0,2*pi,50);
x=abs(b+a*sin(c*t)).*cos(t);
y=abs(b+a*sin(c*t)).*sin(t);
z=a*cos(c*t);
plot3(x,y,z);
the proble is that the plot is not what is expected in the question,and the same problem I have with 3 more questions. Can someone help me to find the problem?:)
thank,

 採用された回答

Jan
Jan 2011 年 12 月 19 日

0 投票

The plot looks "crazy" because the stepwidth is very long. Simply increase the number of points:
a=0.2;
b=0.8;
c=20;
t=linspace(0,2*pi, 500); % 50 --> 500
x=abs(b+a*sin(c*t)).*cos(t);
y=abs(b+a*sin(c*t)).*sin(t);
z=a*cos(c*t);
plot3(x,y,z);

その他の回答 (1 件)

Sean de Wolski
Sean de Wolski 2011 年 12 月 19 日

0 投票

a=0.2; b=0.8; c=20;
t=linspace(0,2*pi,50);
x=abs(b+a*sin(c*t)).*cos(t);
y=abs(b+a*sin(c*t)).*sin(t);
z=a*cos(c*t);
plot3(x,y,z,'*');
Shows the shape you're looking for. By only plotting the markers and not the line, the order of the points does not matter. Did you want the points connected/the outside surface surfed? If so, then you need to figure out how to connect them, i.e order them and/or generate facets.

1 件のコメント

Valery
Valery 2011 年 12 月 19 日
I hope I understand you right, but I think I dont need yo conect to the outside surface but only create three-dimensional curves in some nice shape:),but the problam that the plot I get is crazy ...

サインインしてコメントする。

カテゴリ

質問済み:

2011 年 12 月 19 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by