beginer| basic problem with bad plot results
Show older comments
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,
Accepted Answer
More Answers (1)
Sean de Wolski
on 19 Dec 2011
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.
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!