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,
采纳的回答
更多回答(1 个)
Sean de Wolski
2011-12-19
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!