beginer| basic problem with bad plot results
Afficher commentaires plus anciens
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,
Réponse acceptée
Plus de réponses (1)
Sean de Wolski
le 19 Déc 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.
1 commentaire
Valery
le 19 Déc 2011
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!