What fuction can I use for represente time as an angle?

조회 수: 2 (최근 30일)
Perla González Pereyra
Perla González Pereyra 2021년 6월 8일
댓글: Jonas 2021년 6월 9일
Hi! Brefly, I have some latencies of neurons that i want to represent in a circular plot, the total circle representes an interval of 300ms an the latencies goes from the origin to the correspond angle as a clockwise.
For example if 300ms is 360° then 150ms will be an angle of 180°, like:
latencies= [50; 240; 151; 122; 170];
interval=300;
angles[];
for r=1:size(latencies,1)
angle=latencies(r,1)*360/interval
angles=[angles;angle]
end
angles=[60; 288; 181.2; 146.4; 204];
I think compass is the more accurate to what i want to do, but in the example i really dont get how the "v" varible works when I see the graph in my case "u" will be the same number because i dont want to put another magnitud for now
u = [5 3 -4 -3 5];
v = [1 5 3 -2 -6];
compass(u,v)
Do you have some suggestion?
  댓글 수: 1
Perla González Pereyra
Perla González Pereyra 2021년 6월 8일
So, I replace 360 for pi values:
for r=1:size(latencies,1)
angle=latencies(r,1)*(2*pi)/interval
angles=[angles;angle]
end
and then create a u vector
u=ones(size(latencies))
and use polarplot
polarplot(angles,u,'o')
rlim([0 1])
And get what i want, but how do i conect this points to the origin? Help.

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

채택된 답변

Jonas
Jonas 2021년 6월 8일
편집: Jonas 2021년 6월 8일
first thing: you can calculate all your angles directly using the formula in your for loop:
angles=latencies*360/interval;
to your question: the compass function wants x and y coordinates of your points to which the arrows are pointing, you can get them using the cos() and the sin() on the angles (dont forget comversion from degree to rad)
angles=[45 0 180 70];
angles=angles/180*pi;
compass(cos(angles),sin(angles))
edit: instead of conversion you can use the cosd() and sind() function which takes the inputs as degrees instead of rad
  댓글 수: 3
Perla González Pereyra
Perla González Pereyra 2021년 6월 8일
Jonas! I finally get it
I used this new angles and your sugest
compass(cos(angles),sin(angles))
And finally get the plot!
Thank u so much!
Jonas
Jonas 2021년 6월 9일
sorry for the short confusion, i edited my answer shortly after creation, i thought you would not read that fast ;-)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Polar Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by