Direction of display of loop

조회 수: 8 (최근 30일)
Raviteja
Raviteja 2011년 3월 21일
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?

채택된 답변

Andrew Newell
Andrew Newell 2011년 3월 21일
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)

추가 답변 (2개)

Doug Hull
Doug Hull 2011년 3월 21일
t = linspace(0,2*pi);
x = cos(t)*sqrt(5);
y = sin(t)*sqrt(5/2);
comet(x,y)
  댓글 수: 1
Raviteja
Raviteja 2011년 3월 21일
I want to know the direction after the plot is completed.
I need direction in static plot.
Can you suggest me anything?

댓글을 달려면 로그인하십시오.


Paulo Silva
Paulo Silva 2011년 3월 21일
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
Paulo Silva
Paulo Silva 2011년 3월 21일
I updated the code, the part with the if statement does what you need?
Raviteja
Raviteja 2011년 3월 21일
It is working! Thanks!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by