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,

 采纳的回答

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 个)

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 个评论

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 ...

请先登录,再进行评论。

类别

Community Treasure Hunt

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

Start Hunting!

Translated by