Direction of display of loop

t = linspace(0,2*pi);
x = cos(t)*sqrt(5);
y = sin(t)*sqrt(5/2);
plot(x,y)
The above code is generating a circle. I want to know the direction it is rotating. How can I do it in Matlab?

 Réponse acceptée

Andrew Newell
Andrew Newell le 21 Mar 2011

0 votes

How about this?
t = linspace(0,2*pi);
x = cos(t)*sqrt(5);
y = sin(t)*sqrt(5/2);
plot(x,y); hold on
quiver(x(1),y(1),x(2)-x(1),y(2)-y(1),10)

Plus de réponses (2)

Doug Hull
Doug Hull le 21 Mar 2011

0 votes

t = linspace(0,2*pi);
x = cos(t)*sqrt(5);
y = sin(t)*sqrt(5/2);
comet(x,y)

1 commentaire

Raviteja
Raviteja le 21 Mar 2011
I want to know the direction after the plot is completed.
I need direction in static plot.
Can you suggest me anything?

Connectez-vous pour commenter.

Paulo Silva
Paulo Silva le 21 Mar 2011

0 votes

t = linspace(0,2*pi);
x = cos(t)*sqrt(5);
y = sin(t)*sqrt(5/2);
plot(x,y)
%text showing the location of 3 points
text(x(1),y(1),'\leftarrow 1')
text(x(10),y(10),'\leftarrow 10')
text(x(30),y(30),'\leftarrow 30')
%arrow showing the direction of the "loop"
if y(1)<y(10)
xlabel('it''s rotating counterclockwise')
text(x(1),y(1),'\uparrow','FontSize',18) %draw arrow
else
xlabel('it''s rotating clockwise')
text(x(1),y(1),'\downarrow','FontSize',18) %draw arrow
end

3 commentaires

Raviteja
Raviteja le 21 Mar 2011
So, Do we need to give some locations to show its direction?
Because I am using one zig zag map near about 20000 samples . Then how many times I have to define the different points as you told?
Is there any other method to to aromatically show directions with arrows or any other?
Paulo Silva
Paulo Silva le 21 Mar 2011
I updated the code, the part with the if statement does what you need?
Raviteja
Raviteja le 21 Mar 2011
It is working! Thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D 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!

Translated by